-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.config.js
77 lines (72 loc) · 1.51 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* eslint-disable filenames/match-exported, sort-keys */
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import {terser} from 'rollup-plugin-terser';
import sourcemaps from 'rollup-plugin-sourcemaps';
import pkg from './package.json';
// eslint-disable-next-line no-process-env
const production = process.env.NODE_ENV === 'production';
const plugins = [
sourcemaps(),
babel({
exclude: [
'../../node_modules/**',
'node_modules/**'
],
plugins: ['external-helpers']
}),
resolve({
customResolveOptions: {
moduleDirectory: [
'node_modules',
'../../node_modules'
]
}
}),
commonjs()
];
// NOTE: see https://github.com/rollup/rollup/issues/408 to understand why we silences `THIS_IS_UNDEFINED` warnings
const onwarn = (warning, warn) => {
if (warning.code === 'THIS_IS_UNDEFINED') {
return;
}
warn(warning);
};
const config = [
{
input: 'src/index.js',
onwarn,
output: {
sourcemap: true,
name: pkg.name,
file: pkg.browser,
format: 'umd'
},
plugins: [
...plugins,
production && terser()
]
},
{
input: 'src/index.js',
onwarn,
output: {
sourcemap: true,
file: pkg.module,
format: 'es'
},
plugins
},
{
input: 'src/index.js',
onwarn,
output: {
sourcemap: true,
file: pkg.main,
format: 'cjs'
},
plugins
}
];
export default config;