-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
69 lines (66 loc) · 1.87 KB
/
rollup.config.mjs
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
import path from "path";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import { terser } from "rollup-plugin-terser";
import { dts } from "rollup-plugin-dts"; // 引入 dts 插件
import { visualizer } from "rollup-plugin-visualizer";
const getPath = (_path) => path.resolve(__dirname, _path);
export default {
input: getPath("src/index.ts"),
plugins: [
resolve({
browser: true, // 确保浏览器环境下加载 browser 字段指定的模块
}),
commonjs({
namedExports: {
"node_modules/konva/konva.js": ["canvas"],
'konva': ['DD' , 'canvas'] // 强制保留 Konva.DD
},
}),
terser({
mangle: {
toplevel: true, // 混淆顶层作用域的变量名和函数名
},
}),
typescript({
tsconfig: getPath("./tsconfig.json"),
extensions: ["ts"],
tsconfigOverride: {
compilerOptions: {
module: "ES2015",
},
},
declaration: true,
declarationDir: "dist/types/",
}),
// visualizer({
// filename: "stats.html",
// open: true,
// }),
],
// external: ['canvas'], // 将未解析的依赖标记为外部依赖
external: ["canvas" , "lunar-typescript"], // 将 canvas 模块排除在外
output: [
{
file: "dist/index.esm.js", // 输出 ESM 模块
format: "esm",
sourcemap: false, // 生成 sourcemap 方便调试
},
],
};
// // 单独处理类型定义文件输出
// export const dtsConfig = {
// input: "dist/types/index.d.ts", // 确保使用正确的类型定义文件路径
// output: {
// file: "dist/index.d.ts", // 输出 .d.ts 类型定义
// format: "es",
// },
// plugins: [
// dts(),
// visualizer({
// filename: "stats.html",
// open: true,
// }),
// ],
// };