-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.js
54 lines (51 loc) · 1.27 KB
/
rollup.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
const path = require('path')
const rollup = require('rollup')
const babel = require('rollup-plugin-babel')
const commonjs = require('rollup-plugin-commonjs')
const nodeResolve = require('rollup-plugin-node-resolve')
const peerDependencies = Object.keys(require('./package.json').peerDependencies)
const entries = [
{
entry: 'src/tanok.js',
moduleName: 'tanok',
},
{
entry: 'src/streamWrapper.js',
moduleName: 'tanokStreamWrapper',
},
]
const plugins = [
babel({
"presets": [ "es2015-rollup", "stage-0", "react" ],
"plugins": [ "transform-decorators-legacy",
["transform-es2015-classes", {loose: true}],
"transform-object-rest-spread"
],
"babelrc": false
}),
nodeResolve({
customResolveOptions: {
moduleDirectory: 'node_modules'
}}),
commonjs(),
]
entries.forEach((entry) => {
rollup.rollup({
input: entry.entry,
plugins: plugins,
external: peerDependencies
}).then(
(bundle) => bundle.write({
file: entry.entry.replace('src', 'lib'),
format: 'umd',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
name: entry.moduleName
}),
(error) => {
console.error(error)
}
)
});