-
Notifications
You must be signed in to change notification settings - Fork 47
/
rollup.main.config.js
38 lines (32 loc) · 978 Bytes
/
rollup.main.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
import babel from 'rollup-plugin-babel';
import nodeResolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import commonjs from 'rollup-plugin-commonjs';
import Visualizer from 'rollup-plugin-visualizer';
const entries = {
min: 'lib/index.js',
umd: 'lib/index.js',
};
const dests = {
min: 'dist/components.min.js',
umd: 'dist/components.js',
}
const { NODE_ENV = 'umd' } = process.env;
export default {
input: entries[NODE_ENV],
context: 'this',
external: ['diffhtml'],
output: [{
file: dests[NODE_ENV],
format: 'umd',
name: 'components',
globals: { diffhtml: 'diff' },
}],
plugins: [
NODE_ENV === 'min' && replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
babel(),
nodeResolve({ mainFields: ['main', 'module'] }),
commonjs({ include: 'node_modules/**' }),
NODE_ENV === 'umd' && Visualizer({ filename: './dist/components-build-size.html' }),
].filter(Boolean),
};