Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
60 lines (58 loc) · 2.15 KB
/
Copy pathvite.config.ts
File metadata and controls
60 lines (58 loc) · 2.15 KB
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// Pages 部署到 https://<user>.github.io/sql_to_ER/,资源路径需要带前缀。
// CI 通过 BASE_PATH=/sql_to_ER/ 注入;本地开发保持 "/".
const base = process.env.BASE_PATH || "/";
export default defineConfig({
base,
plugins: [react()],
build: {
// 隐藏式 sourcemap:产物里不写 sourceMappingURL 注释,但 .map 文件会生成,
// 便于线上报错时本地对照定位;部署工作流不会把 .map 发布出去。
sourcemap: "hidden",
// G6 4.x pulls a large @antv graph-rendering stack. It is split into
// stable vendor chunks below; keep the warning threshold aligned with that
// known dependency cost so warnings remain actionable.
chunkSizeWarningLimit: 1100,
rollupOptions: {
input: {
main: "index.html",
app: "sql2er.html",
},
output: {
manualChunks(id) {
if (id.includes("node_modules/@antv/g6")) {
return "vendor-g6";
}
if (id.includes("node_modules/@antv/")) return "vendor-antv";
if (
id.includes("node_modules/d3-") ||
id.includes("node_modules/dagre") ||
id.includes("node_modules/graphlib")
) {
return "vendor-antv";
}
if (id.includes("node_modules/react") || id.includes("node_modules/react-dom")) {
return "vendor-react";
}
if (
id.includes("node_modules/codemirror") ||
id.includes("node_modules/@codemirror") ||
id.includes("node_modules/@lezer")
) {
return "vendor-editor";
}
// prismjs/components/* 在模块顶层访问全局 Prism,必须落在独立 chunk
// 里,等运行时显式 window.Prism = Prism 后再动态加载,否则会和 core 一起
// 被同步求值并抛 ReferenceError。
if (
id.includes("node_modules/prismjs") &&
!id.includes("node_modules/prismjs/components/")
) {
return "vendor-prism";
}
},
},
},
},
});