-
Notifications
You must be signed in to change notification settings - Fork 128
/
rollup.config.js
78 lines (76 loc) · 2.08 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const json = require('rollup-plugin-json')
const resolve = require('rollup-plugin-node-resolve')
const commentjs = require('rollup-plugin-commonjs')
const babel = require('rollup-plugin-babel')
const vue = require('rollup-plugin-vue')
const eslint = require('rollup-plugin-eslint')
const uglify = require('rollup-plugin-uglify')
const autoprefixer = require('autoprefixer')
const clean = require('postcss-clean')
const postcss = require('postcss')
const fs = require('fs')
const { version } = require('./package.json')
let production = /^production/.test(process.env.BUILD)
let min = process.env.BUILD === 'production-min'
module.exports = {
entry: 'src/main.js',
dest: `${production ? 'dist' : 'docs/src/croppa'}/vue-croppa${
min ? '.min' : ''
}.js`,
format: 'umd',
moduleName: 'Croppa',
sourceMap: production ? false : 'inline',
banner: `\
/*
* vue-croppa v${version}
* https://github.com/zhanziyang/vue-croppa
*
* Copyright (c) ${new Date().getFullYear()} zhanziyang
* Released under the ISC license
*/
`,
plugins: [
commentjs(),
resolve(),
json(),
vue({
css: function(css, allStyles, compile) {
postcss(min ? [autoprefixer, clean] : [autoprefixer])
.process(css)
.then(function(result) {
result.warnings().forEach(function(warn) {
console.warn(warn.toString())
})
fs.writeFile(
`${production ? 'dist' : 'docs/src/croppa'}/vue-croppa${
min ? '.min' : ''
}.css`,
result.css,
err => {
if (err) throw err
}
)
})
}
}),
production && eslint(),
babel({
presets: [
[
'es2015',
{
modules: false
}
]
],
plugins: ['external-helpers', 'transform-object-rest-spread'],
exclude: 'node_modules/**'
}),
min &&
uglify({
output: {
comments: /zhanziyang/
}
})
]
}