-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rollup.js
37 lines (32 loc) · 1.04 KB
/
.rollup.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
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
const isBrowser = String(process.env.NODE_ENV).includes('browser');
const isBrowserMin = String(process.env.NODE_ENV).includes('browser:min');
// support IE9+ browsers, otherwise node 6+
const targets = isBrowser ? 'ie >= 9' : { node: 6 };
// write to jshape.js/jshape.min.js for browsers, index.cjs.js/index.esm.mjs for node
const output = isBrowser
? { file: `jshape${isBrowserMin ? '.min' : ''}.js`, format: 'iife', name: 'jshape', sourcemap: !isBrowserMin }
: [
{ file: 'index.js', format: 'cjs', sourcemap: true },
{ file: 'index.mjs', format: 'es', sourcemap: true }
];
// use babel, and also terser to minify jshape.min.js
const plugins = [
babel({
presets: [
['@babel/env', { targets }]
]
})
].concat(
isBrowserMin
? terser({
mangle: {
properties: {
reserved: ['asArray', 'asBoolean', 'asHashmap', 'asNumber', 'asOptional', 'asShape', 'asString', 'value']
}
}
})
: []
);
export default { input: 'src/index.js', output, plugins };