-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathrollup.config.js
executable file
·53 lines (51 loc) · 1.49 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
import { babel } from "@rollup/plugin-babel"
import terser from "@rollup/plugin-terser"
import commonjs from "@rollup/plugin-commonjs"
import nodePolyfills from 'rollup-plugin-polyfill-node'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
const globals = {
"dayjs": "dayjs",
"md5": "md5",
"qs": "qs",
"crypto-js": "crypto"
}
/**
* amd - 异步模块加载,适用于 RequireJS 等模块加载器
* cjs - CommonJS,适用于 Node 环境和其他打包工具(别名:commonjs)
* es - 将 bundle 保留为 ES 模块文件,适用于其他打包工具,以及支持 <script type=module> 标签的浏览器(别名:esm,module)
* iife - 自执行函数,适用于 <script> 标签
* umd - 通用模块定义规范,同时支持 amd,cjs 和 iife
* system - SystemJS 模块加载器的原生格式(别名:systemjs)
*/
export default {
input: "src/device.js",
plugins: [
json(),
nodeResolve({
exportConditions: ["node", "browser"],
preferBuiltins: true,
browser: true
}),
commonjs(),
nodePolyfills(),
babel({babelHelpers: "runtime", exclude: /node_modules/}),
terser()
],
output: [
{
file: `dist/device.es.js`,
format: "es",
compact: true, // 是否压缩 Rollup 产生的额外代码
globals: globals
},
{
file: `dist/device.js`,
name: 'Device',
format: 'umd',
compact: true,
globals: globals
}
],
context: "window"
}