-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
executable file
·133 lines (125 loc) · 2.72 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import url from 'rollup-plugin-url';
import { uglify } from 'rollup-plugin-uglify';
import builtins from 'rollup-plugin-node-builtins';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import pkg from './package.json';
const peerDeps = Object.keys(pkg.externals);
const makeConfig = ({ input, output, minify, dependencies }) => ({
input,
output: {
...output,
},
external: Array.isArray(dependencies) ? dependencies : [],
plugins: [
external(),
builtins(),
postcss({
// modules: true,
}),
url(),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
}),
resolve({
extensions: ['.js', '.jsx', '.json'],
customResolveOptions: {
moduleDirectory: 'node_modules',
}
}),
commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/react-is/index.js': ['isValidElementType'],
},
}),
minify && uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
},
}),
sizeSnapshot(),
].filter(Boolean),
});
export default [
makeConfig({
input: 'src/index.js',
minify: true,
output: {
file: pkg.unpkg,
format: 'umd',
name: 'Questrar',
sourcemap: true,
globals: pkg.externals
},
dependencies: peerDeps
}),
makeConfig({
input: 'src/index.js',
output: {
file: pkg.main,
format: 'cjs',
sourcemap: true,
globals: pkg.externals
},
dependencies: peerDeps
}),
makeConfig({
input: 'src/index.js',
output: {
file: 'questrar-esm.js',
dir: 'esm',
format: 'es',
sourcemap: true
},
dependencies: peerDeps
}),
// redux
makeConfig({
input: 'src/redux/index.js',
output: {
file: 'questrar-redux-cjs.js',
dir: 'lib',
format: 'cjs',
sourcemap: true
}
}),
makeConfig({
input: 'src/redux/index.js',
output: {
file: 'questrar-redux-esm.js',
dir: 'esm',
format: 'es',
sourcemap: true
},
dependencies: peerDeps
}),
// store
makeConfig({
input: 'src/store/index.js',
output: {
file: 'questrar-store-cjs.js',
dir: 'lib',
format: 'cjs',
sourcemap: true
}
}),
makeConfig({
input: 'src/store/index.js',
output: {
file: 'questrar-store-esm.js',
dir: 'esm',
format: 'es',
sourcemap: true
},
dependencies: peerDeps
}),
];