This repository has been archived by the owner on Dec 12, 2020. It is now read-only.
forked from OnsenUI/OnsenUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
80 lines (76 loc) · 2.2 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pkg from './package.json';
import dateformat from 'dateformat';
// Rollup plugins
import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import string from 'rollup-plugin-string';
import filesize from 'rollup-plugin-filesize';
import progress from 'rollup-plugin-progress';
import visualizer from 'rollup-plugin-visualizer';
import execute from 'rollup-plugin-execute';
const banner = name => `/* ${name} v${pkg.version} - ${dateformat(new Date(), 'yyyy-mm-dd')} */\n`;
const stringOpt = { include: '**/*.svg', }; // SVG images
const cjsOpt = { include: 'node_modules/**' };
const babelrc = Object.assign({}, pkg.babel);
babelrc.babelrc = babelrc.presets[0][1].modules = false;
babelrc.plugins = ['external-helpers'];
export default [
// Core UMD
{
input: 'core/src/index.umd.js',
output: {
file: 'build/js/onsenui.js',
format: 'umd',
name: 'ons',
sourcemap: 'inline',
banner: banner(pkg.name),
},
plugins: [
eslint({
include: [
'core/src/**/*.js',
],
exclude: [
'core/src/polyfills/**/*.js',
'core/src/vendor/**/*.js'
]
}),
string(stringOpt),
resolve(),
commonjs(cjsOpt),
babel(babelrc),
progress(),
filesize(),
visualizer({
filename: 'module-stats.umd.html',
sourcemap: true, // Shows minified sizes
}),
execute(`node_modules/.bin/uglifyjs build/js/${pkg.name}.js -c -m --comments '/${pkg.name} v/' --output build/js/${pkg.name}.min.js`),
],
},
// Core ES Modules
{
input: 'core/src/index.esm.js',
external: id => /\/ons\//.test(id), // Do not bundle 'ons', only polyfills/vendor
output: {
file: 'build/esm/index.js',
format: 'es',
name: 'onsESM',
sourcemap: 'inline',
banner: banner(pkg.name),
},
plugins: [
resolve(),
commonjs(cjsOpt),
babel(babelrc),
progress(),
filesize(),
visualizer({
filename: 'module-stats.esm.html',
sourcemap: false, // Unminified to show core-js size
}),
],
}
];