-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
49 lines (42 loc) · 1.18 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
/* eslint no-console: 0 */
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import compact from 'lodash.compact';
import pkg from './package.json';
const prod = process.env.PRODUCTION;
const esbundle = process.env.ES;
const cjs = process.env.CJS;
const umd = process.env.UMD;
const config = {
input: 'src/index.js',
name: 'TypingMonitor',
};
const base = pkg.main.split('.')[0];
if (esbundle) {
console.log('\nCreating ES bundle...');
config.output = { format: 'es', file: pkg.module };
} else if (cjs) {
console.log('\nCreating production CJS bundle...');
config.output = { format: 'cjs', file: pkg.main };
} else if (umd && prod) {
console.log('\nCreating development UMD bundle...');
config.output = { format: 'umd', file: `${base}.umd.min.js` };
} else if (umd) {
console.log('\nCreating production UMD bundle...');
config.output = { format: 'umd', file: `${base}.umd.js` };
}
if (umd) config.sourcemap = true;
config.plugins = compact([
babel({
babelrc: false,
presets: [
['env', { modules: false }],
'flow',
],
plugins: [
'external-helpers',
],
}),
prod && uglify(),
]);
export default config;