forked from router5/router5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
56 lines (51 loc) · 1.73 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
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import nodeResolve from 'rollup-plugin-node-resolve';
import common from 'rollup-plugin-commonjs';
const babelOptions = {
runtimeHelpers: true,
presets: [['es2015', { modules: false }]],
plugins: [
'external-helpers',
'transform-object-rest-spread',
'transform-class-properties',
'transform-export-extensions'
],
babelrc: false
};
const modules = {
router5: 'packages/router5/modules/index.js',
router5BrowserPlugin: 'packages/router5/modules/plugins/browser/index.js',
router5ListenersPlugin:
'packages/router5/modules/plugins/listeners/index.js',
persistentParamsPlugin:
'packages/router5/modules/plugins/persistentParams/index.js',
reactRouter5: 'packages/react-router5/modules/index.js',
reduxRouter5: 'packages/redux-router5/modules/index.js',
router5Helpers: 'packages/router5-helpers/modules/index.js'
};
const modulesToBuild = Object.keys(modules).reduce((acc, moduleName) => {
const base = {
format: 'umd',
entry: modules[moduleName],
external: ['react'],
moduleName
};
const packageDir = modules[moduleName].match(/^packages\/([\w-]+)\//)[1];
const plugins = [
common({ include: `packages/${packageDir}/node_modules/**` }),
babel(babelOptions),
nodeResolve({ jsnext: true })
];
return acc.concat([
Object.assign({}, base, {
dest: `dist/${moduleName}.js`,
plugins
}),
Object.assign({}, base, {
dest: `dist/${moduleName}.min.js`,
plugins: plugins.concat(uglify())
})
]);
}, []);
export default modulesToBuild;