-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
59 lines (54 loc) · 1.46 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
import path from 'path';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import { uglify } from 'rollup-plugin-uglify';
import filesize from 'rollup-plugin-filesize';
import pkg from './package.json';
const filter = arr => arr.filter(x => !!x);
const argv = process.argv.slice(2);
const isProduction = !argv.includes('--watch') && !argv.includes('-w');
const { main } = pkg;
const extname = path.extname(pkg.main);
const defaultPlugins = filter([
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
}),
commonjs(),
isProduction && filesize(),
]);
const configuration = ({ format, dest, plugins = defaultPlugins } = {}) => ({
input: 'src/index.js',
external: ['react', 'prop-types'],
output: {
file: dest,
name: 'ReactInfiniteScrollList',
format,
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
},
plugins,
});
export default filter([
configuration({ format: 'es', dest: pkg.module }),
isProduction && configuration({ format: 'umd', dest: main }),
isProduction &&
configuration({
format: 'umd',
dest: `${main.substring(0, main.length - extname.length)}.min${extname}`,
plugins: defaultPlugins.concat([
uglify({
compress: {
warnings: false,
comparisons: false,
},
output: {
comments: false,
ascii_only: true,
},
}),
]),
}),
]);