-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrollup.config.js
93 lines (84 loc) · 2.13 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import svg from 'rollup-plugin-svg';
import { terser } from 'rollup-plugin-terser';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import pkg from './package.json';
// treat as externals not relative, not absolute and not reserved rollup paths
const external = id => !id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/');
const input = './src/components/index.jsx';
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
};
const getBabelOptions = ({ useESModules }) => ({
exclude: 'node_modules/**',
runtimeHelpers: true,
plugins: [
['@babel/transform-runtime', { useESModules }],
],
});
const commonjsOptions = {
include: 'node_modules/**',
};
export default [
{
input,
external,
output: { file: pkg.main, format: 'cjs', sourcemap: true },
plugins: [
resolve({ extensions: ['.js', '.jsx'] }),
babel(getBabelOptions({ useESModules: false })),
svg(),
sizeSnapshot(),
],
},
{
input,
external,
output: { file: pkg.module, format: 'esm', sourcemap: true },
plugins: [
resolve({ extensions: ['.js', '.jsx'] }),
babel(getBabelOptions({ useESModules: true })),
svg(),
commonjs(commonjsOptions),
sizeSnapshot(),
],
},
{
input,
external: Object.keys(globals),
output: {
globals,
format: 'umd',
name: pkg.name,
file: 'dist/laboratoria-ui.umd.js',
},
plugins: [
resolve({ extensions: ['.js', '.jsx'] }),
babel(getBabelOptions({ useESModules: true })),
svg(),
commonjs(commonjsOptions),
sizeSnapshot(),
],
},
{
input,
external: Object.keys(globals),
output: {
globals,
format: 'umd',
name: pkg.name,
file: 'dist/laboratoria-ui.umd.min.js',
},
plugins: [
resolve({ extensions: ['.js', '.jsx'] }),
babel(getBabelOptions({ useESModules: true })),
svg(),
commonjs(commonjsOptions),
terser(),
],
},
];