forked from router5/router5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
62 lines (57 loc) · 1.9 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
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: [['env', { modules: false }], 'react'],
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 = {
input: modules[moduleName],
external: ['react']
}
const packageDir = modules[moduleName].match(/^packages\/([\w-]+)\//)[1]
const plugins = [
nodeResolve({ jsnext: true, module: true }),
common({ include: `packages/${packageDir}/node_modules/**` }),
babel(babelOptions)
]
return acc.concat([
Object.assign({}, base, {
output: {
file: `dist/${moduleName}.js`,
name: moduleName,
format: 'umd'
},
plugins
}),
Object.assign({}, base, {
output: {
file: `dist/${moduleName}.min.js`,
name: moduleName,
format: 'umd'
},
plugins: plugins.concat(uglify())
})
])
}, [])
export default modulesToBuild