-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.js
68 lines (59 loc) · 1.88 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
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace'
import uglify from 'rollup-plugin-uglify';
import pkg from './package.json';
const input = 'src/index.js';
const onwarn = function(warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
// console.warn everything else
console.log('\x1b[33m(!) %s\x1b[0m', warning.message || warning);
};
const plugins = [
replace({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) }),
resolve(), // so Rollup can resolve node_modules
babel({
exclude: ['node_modules/**'],
plugins: ["external-helpers"]
}),
commonjs(), // so Rollup can convert commonjs to an ES module
];
// browser-friendly UMD build
const umd = {
input,
output: {
file: pkg.browser,
format: 'umd',
name: 'VirtualScroller',
},
onwarn,
plugins
};
if (process.env.NODE_ENV === 'development') {
// nothing current
} else if (process.env.NODE_ENV === 'production') {
const prodPlugins = [
uglify({
compress: {
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebookincubator/create-react-app/issues/2376
// Pending further investigation:
// https://github.com/mishoo/UglifyJS2/issues/2011
comparisons: false,
},
output: {
comments: false,
// Turned on because emoji and regex is not minified properly using default
// https://github.com/facebookincubator/create-react-app/issues/2488
ascii_only: true,
},
})
]
umd.output.file = umd.output.file.replace(/js$/, 'min.js');
umd.plugins = umd.plugins.concat(prodPlugins);
}
export default umd;