-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
47 lines (41 loc) · 1.11 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
import babel from 'rollup-plugin-babel';
import sourceMaps from 'rollup-plugin-sourcemaps';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
const cjs = (overrides = {}) => ({
exports: 'named',
format: 'cjs',
sourcemap: true,
...overrides,
});
const prodPlugins = [
terser({
mangle: { module: true },
sourcemap: true,
}),
];
const plugins = ({ immutable, prod }) => [
babel(),
sourceMaps(),
replace({
'process.env.IMMUTABLE': JSON.stringify(immutable),
'process.env.NODE_ENV': JSON.stringify(prod ? 'production' : 'development'),
}),
...(prod ? prodPlugins : []),
];
const config = ({ immutable = false, prod = false, format = cjs } = {}) => {
const env = prod ? '' : 'dev.';
const immut = immutable ? 'immutable.' : '';
const prefix = `dist/structure-ops.${immut}${env}`;
return {
input: './src/index.js',
output: [format({ file: `${prefix}cjs.js` })],
plugins: plugins({ immutable, prod }),
};
};
export default [
config(),
config({ prod: true }),
config({ immutable: true }),
config({ immutable: true, prod: true }),
];