-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (51 loc) · 1.07 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
import resolve from '@rollup/plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import { terser } from 'rollup-plugin-terser'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from 'autoprefixer'
let jsFileName = 'campo-ui'
let cssFileName = 'campo-ui'
let jsPlugins = [
resolve(),
babel({
exclude: 'node_modules/**'
})
]
let postcssConfig = {
extract: true,
sourceMap: true,
plugins: [autoprefixer()]
}
if (process.env.BUNDLE) {
jsFileName += '.bundle'
}
if (process.env.MINIMIZE) {
jsFileName += '.min'
cssFileName += '.min'
jsPlugins.push(terser())
postcssConfig.minimize = true
}
const rollupConfig = [{
input: 'src/js/campo-ui.js',
output: {
file: `dist/js/${jsFileName}.js`,
format: 'umd',
name: 'CampoUI',
sourcemap: true,
globals: {
stimulus: 'Stimulus'
}
},
context: 'window',
external: ['stimulus'],
plugins: jsPlugins
}, {
input: 'src/css/index.js',
output: [{
file: `dist/css/${cssFileName}.js`
}],
plugins: [
postcss(postcssConfig)
]
}]
export default rollupConfig