-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
55 lines (48 loc) · 1.36 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
import nodeResolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import inject from 'rollup-plugin-inject'
import babel from 'rollup-plugin-babel'
import json from 'rollup-plugin-json'
import uglify from 'rollup-plugin-uglify'
const processShim = '\0process-shim'
const prod = process.env.PRODUCTION
const mode = prod ? 'production' : 'development'
console.log(`Creating ${mode} bundle...`)
const targets = prod
? [{ dest: 'dist/cycle-fela.min.js', format: 'umd' }]
: [{ dest: 'dist/cycle-fela.js', format: 'umd' }, { dest: 'dist/cycle-fela.es.js', format: 'es' }]
const plugins = [
{
resolveId(importee) {
if (importee === processShim) return importee
return null
},
load(id) {
if (id === processShim) return 'export default { argv: [], env: {} }'
return null
},
},
nodeResolve(),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify(prod ? 'production' : 'development'),
}),
inject({
process: processShim,
}),
babel({
babelrc: false,
presets: [['latest', { es2015: { modules: false } }]],
plugins: ['external-helpers', 'transform-object-rest-spread'],
}),
json(),
]
if (prod) plugins.push(uglify())
export default {
entry: 'src/index.js',
moduleName: 'cycle-fela',
exports: 'named',
targets,
plugins,
}