-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrollup.config.mjs
85 lines (78 loc) · 1.67 KB
/
rollup.config.mjs
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
78
79
80
81
82
83
84
85
import { babel } from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import clear from 'rollup-plugin-clear';
import ignore from 'rollup-plugin-ignore';
import postcss from 'rollup-plugin-postcss';
import prettier from 'rollup-plugin-prettier';
import progress from 'rollup-plugin-progress';
import rfdc from 'rfdc';
const clone = rfdc();
const defaultOutput = {
globals: {
'@babel/runtime/helpers/extends': '_extends',
'd3-ease': 'd3',
'd3-hierarchy': 'd3',
react: 'React'
},
interop: 'auto'
};
const defaultConfig = {
external: [
'@babel/runtime/helpers/extends',
'd3-hierarchy',
'd3-ease',
'react'
],
input: 'src/index.js',
plugins: [
babel({
babelHelpers: 'runtime',
exclude: 'node_modules/**',
plugins: ['@babel/plugin-transform-runtime']
}),
clear({
targets: ['dist']
}),
progress()
]
};
const devConfig = clone(defaultConfig);
devConfig.output = {
...defaultOutput,
file: 'dist/index.js',
format: 'umd',
name: 'ReactTreeGraph'
};
devConfig.plugins.push(prettier({
parser: 'babel',
singleQuote: true,
useTabs: true
}));
devConfig.plugins.unshift(postcss({
extract: 'style.css'
}));
const moduleConfig = clone(defaultConfig);
moduleConfig.output = {
...defaultOutput,
dir: 'dist/module',
format: 'esm',
preserveModules: true
};
moduleConfig.plugins.unshift(ignore(['../styles/style.css']));
const prodConfig = clone(defaultConfig);
prodConfig.output = {
...defaultOutput,
file: 'dist/index.min.js',
format: 'umd',
name: 'ReactTreeGraph'
};
prodConfig.plugins.push(terser());
prodConfig.plugins.unshift(postcss({
extract: 'style.min.css',
minimize: true
}));
export default [
devConfig,
moduleConfig,
prodConfig
];