-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.js
75 lines (71 loc) · 1.81 KB
/
build.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
'use strict';
const rimraf = require('rimraf');
const rollup = require('rollup').rollup;
const babel = require('rollup-plugin-babel');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const uglify = require('rollup-plugin-uglify');
const packages = [
'animate',
'animo',
'countdown',
'rotate'
];
console.info('building');
packages.forEach(pkg => {
rimraf(`./packages/${pkg}/lib`, () => {
rollup({
entry: `./packages/${pkg}/src/index.js`,
plugins: [
babel({
exclude: 'node_modules/**',
presets: ['es2015-rollup', 'stage-0'],
plugins: []
})
]
}).then(transpile => {
console.info(`writing transpiled package: ${pkg}`);
transpile.write({
format: 'es',
moduleName: pkg,
dest: `./packages/${pkg}/lib/index.js`
});
bundle(pkg);
}).catch(err => {
console.warn(err);
process.exit(1);
});
});
const bundle = pkg => {
rimraf(`./packages/${pkg}/dist`, () => {
rollup({
entry: `./packages/${pkg}/src/index.js`,
plugins: [
babel({
exclude: 'node_modules/**',
externalHelpers: false,
runtimeHelpers: true,
presets: [
'es2015-rollup',
'stage-0'
],
plugins: ['transform-runtime']
}),
commonjs(),
resolve({ jsnext: true, main: true }),
uglify()
]
}).then(bundle => {
console.info(`writing bundled package: ${pkg}`);
bundle.write({
format: 'iife',
moduleName: pkg,
dest: `./packages/${pkg}/dist/index.js`
});
}).catch(err => {
console.warn(err);
process.exit(1);
})
});
}
});