-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
58 lines (52 loc) · 1.28 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
import path from "path";
import resolve from "rollup-plugin-node-resolve"; // 依赖引用插件
import commonjs from "rollup-plugin-commonjs"; // commonjs模块转换插件
import image from "@rollup/plugin-image";
import glslify from "rollup-plugin-glslify";
import ts from "rollup-plugin-typescript2";
import postcss from "rollup-plugin-postcss";
const getPath = (_path) => path.resolve(__dirname, _path);
import packageJSON from "./package.json";
const extensions = [".js", ".ts", ".tsx"];
// 导入本地ts配置
const tsPlugin = ts({
tsconfig: getPath("./tsconfig.json"),
tsconfigOverride: { extensions },
});
// 基础配置
const commonConf = {
// 入口文件
input: getPath("./src/index.ts"),
plugins: [
resolve({
extensions,
}),
glslify(),
commonjs(),
image(),
postcss({ extract: "css/style.css" }),
tsPlugin,
],
};
// 需要导出的模块类型
const outputMap = [
{
file: "dist/bundle.esm.js",
format: "esm",
},
{
file: "dist/bundle.umd.js",
format: "umd",
name: "Copper",
},
];
const buildConf = (options) => Object.assign({}, commonConf, options);
export default outputMap.map((output) => {
const conf = buildConf({
output: {
...output,
name: packageJSON.name,
},
});
return conf;
});