-
-
Notifications
You must be signed in to change notification settings - Fork 186
/
rollup.config.js
51 lines (44 loc) · 1.11 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
import babel from '@rollup/plugin-babel';
import pkg from './package.json';
const mergeAll = objs => Object.assign({}, ...objs);
const commonPlugins = [
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
}),
];
const configBase = {
input: 'src/index.js',
external: Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {})),
plugins: commonPlugins,
};
const devUmdConfig = mergeAll([
configBase,
{
output: {
file: pkg.unpkg.replace(/\.min\.js$/, '.js'),
format: 'umd',
name: 'onClickOutside',
exports: 'named',
globals: { react: 'React', 'react-dom': 'ReactDOM' },
},
external: Object.keys(pkg.peerDependencies || {}),
},
]);
const prodUmdConfig = mergeAll([
devUmdConfig,
{ output: mergeAll([devUmdConfig.output, { file: pkg.unpkg }]) },
{
plugins: devUmdConfig.plugins
},
]);
const webConfig = mergeAll([
configBase,
{
output: [
{ file: pkg.module, format: 'es' },
{ file: pkg.main, format: 'cjs', exports: 'named' }
],
},
]);
export default [devUmdConfig, prodUmdConfig, webConfig];