-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
83 lines (81 loc) · 2.3 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
81
82
83
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import babel from '@rollup/plugin-babel';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
import pkg from './package.json';
// import pkg from './package.json' assert { type: "json" };
const banner = `/*!* ${pkg.name.split('/').slice(-1)}.js v${pkg.version} \n * (c) 2020-${new Date().getFullYear()} ${
pkg.author
} \n * Released under the MIT License. \n */`;
// es: 将 bundle 保留为 ES 模块文件,适用于其他打包工具,以及支持 <script type=module> 标签的浏览器。(别名:esm,module)
// system: SystemJS 模块加载器的原生格式(别名:systemjs)
// ✅amd: 异步模块加载,适用于 RequireJS 等模块加载器
// ✅cjs: CommonJS,适用于 Node 环境和其他打包工具(别名:commonjs)
// ✅iife: 自执行函数,适用于 <script> 标签(如果你想为你的应用程序创建 bundle,那么你可能会使用它)。iife 表示“自执行 函数表达式”
// ✅umd: 通用模块定义规范,同时支持 amd,cjs 和 iife
export default {
input: 'src/index.ts',
output: [
// {
// format: 'system',
// banner,
// file: pkg.system,
// },
// {
// format: 'es',
// banner,
// file: pkg.module,
// },
// {
// format: 'cjs',
// exports: 'auto',
// banner,
// file: pkg.main,
// },
{
format: 'umd',
name: 'dora',
exports: 'named',
banner,
file: pkg.browser.split('.')[0] + '.js',
sourcemap: true,
},
{
format: 'umd',
name: 'dora',
exports: 'named',
banner,
file: pkg.browser,
plugins: [
terser({
compress: {
drop_console: true,
},
format: {
comments: /^!/,
},
}),
],
sourcemap: true,
},
],
external: ['core-js'],
plugins: [
resolve({
moduleDirectories: ['node_modules'],
}),
commonjs(),
typescript({
module: 'ES2015',
sourceMap: true,
}),
babel({
// babelHelpers: 'bundled',
babelHelpers: 'runtime',
exclude: 'node_modules/**',
}),
json(),
],
};