-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
47 lines (41 loc) · 1.1 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
import commonjs from "@rollup/plugin-commonjs"; // 使用commonjs
import resolve from "@rollup/plugin-node-resolve"; // 加载第三方库
import babel from "@rollup/plugin-babel"; // 转成es5
import alias from "@rollup/plugin-alias"; // 别名
import { terser } from "rollup-plugin-terser"; // 压缩代码
import serve from "rollup-plugin-serve"; // 启动服务
import replace from "rollup-plugin-replace"; // 注入环境变量
const __DEV__ = process.env.NODE_ENV === "development";
const plugins = [
alias({
entries: {},
}),
commonjs(),
resolve({ extensions: [".ts", ".tsx", ".js", ".jsx"] }),
replace({ __DEV__ }),
babel({
babelHelpers: "bundled", // 多次使用辅助函数只保留一个 比如 class 在转换成es5时会使用多个辅助函数则只保留一个
}),
];
if (__DEV__) {
plugins.push(
serve({
open: true,
port: process.env.PORT || "8101",
contentBase: "./",
})
);
} else {
plugins.push(terser());
}
export default {
plugins,
input: {
myQuery: "src/",
},
output: {
dir: "dist/",
name: "$",
format: "umd",
},
};