-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
94 lines (86 loc) · 1.82 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
84
85
86
87
88
89
90
91
92
93
94
// rollup.config.js
import livereload from 'rollup-plugin-livereload'
import serve from 'rollup-plugin-serve'
/** 打包nodejs内置工具模块 */
import nodePolyfills from 'rollup-plugin-node-polyfills';
/** 支持ts打包 */
import typescript from "rollup-plugin-typescript";
import dts from "rollup-plugin-dts";
/** 报错追源 */
import sourceMaps from "rollup-plugin-sourcemaps";
/** 压缩打包 */
import { terser } from 'rollup-plugin-terser';
const isDev = process.env.NODE_ENV !== 'production';
const devConfig = {
input: "index.ts", // 入口文件
output: [
{
file: "lib/boundle.js", // 必须
format: "cjs", // 必须
sourcemap: true
},
{
file: "examples/boundle/boundle.js", // 必须
format: 'umd',
name: 'Vact'
}
],
plugins: [
nodePolyfills(),
livereload(),
serve({
// open: true,
port: 3000,
contentBase: './examples'
}),
typescript({
exclude: "node_modules/**",
typescript: require("typescript")
}),
sourceMaps(),
]
};
const proConfig = {
input: "index.ts", // 入口文件
output: [
{
file: "lib/boundle.js", // 必须
format: "cjs", // 必须
sourcemap: true
},
{
file: "lib/boundle.umd.js", // 必须
format: 'umd',
name: 'Vact',
sourcemap: true
},
{
file: "lib/bundle.esm.js",
format: "es",
sourcemap: true
}
],
plugins: [
nodePolyfills(),
typescript({
exclude: "node_modules/**",
typescript: require("typescript")
}),
sourceMaps(),
// terser()
]
};
export default [
isDev ? devConfig : proConfig,
{
// 生成 .d.ts 类型声明文件
input: 'index.ts',
output: {
file: "index.d.ts",
format: 'es',
},
plugins: [
dts()
]
}
]