-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
57 lines (54 loc) · 1.59 KB
/
rollup.config.ts
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
import typescript from "@rollup/plugin-typescript"
import {terser} from "rollup-plugin-terser"
import {babel} from "@rollup/plugin-babel"
import nodePolyfills from 'rollup-plugin-polyfill-node'
import {nodeResolve} from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
const name = "WebEESocket"
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/Index.ts',
plugins: [
json(),
typescript(),
nodeResolve({
exportConditions: ["node", "browser"],
preferBuiltins: true,
browser: true
}),
commonjs(),
nodePolyfills(),
babel({babelHelpers: 'runtime', exclude: /node_modules/}),
terser()
],
output: [
{
file: `dist/${name}.es.js`,
format: 'es',
compact: true, // 是否压缩 Rollup 产生的额外代码
globals: globals
},
{
file: `dist/${name}.js`,
name: "WebEESocket",
format: 'umd',
compact: true,
globals: globals
}
],
context: "window"
}