-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
rollup.config.js
96 lines (88 loc) · 2.02 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import vue from 'rollup-plugin-vue'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from 'autoprefixer'
import { terser } from 'rollup-plugin-terser'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import pkg from './package.json'
const name = 'AvatarCropper'
const outFilename = (infix) => `./dist/avatar-cropper.${infix}.js`
const production =
process.env.NODE_ENV === 'production' && !process.env.ROLLUP_WATCH
const external = Object.keys(pkg.dependencies || {}).concat([
'vue',
'cropperjs/dist/cropper.css',
'mime/lite',
])
const globals = {
cropperjs: 'Cropper',
vue: 'Vue',
'mime/lite': 'mime',
}
const output = []
const plugins = [
vue({
preprocessStyles: false,
template: {
isProduction: production,
compilerOptions: {
whitespace: 'condense',
},
},
}),
postcss({
plugins: [autoprefixer],
}),
peerDepsExternal(),
]
if (production) {
output.push(
{
file: outFilename('esm'),
format: 'esm',
name,
plugins: [
getBabelOutputPlugin({
presets: ['@babel/env'],
plugins: [
'@babel/transform-runtime',
'@babel/transform-regenerator',
'@babel/transform-async-to-generator',
],
}),
terser({ output: { ecma: 6 } }),
],
globals,
},
{
file: outFilename('umd'),
format: 'esm',
name,
plugins: [
getBabelOutputPlugin({
presets: [['@babel/env', { modules: 'umd' }]],
plugins: [
'@babel/transform-runtime',
'@babel/transform-regenerator',
'@babel/transform-async-to-generator',
],
}),
terser({ output: { ecma: 5 } }),
],
globals,
},
)
} else {
output.push({
file: './dev/avatar-cropper.js',
format: 'umd',
name,
globals,
})
}
export default {
input: './src/index.js',
external,
output,
plugins,
}