-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
100 lines (90 loc) · 2.33 KB
/
Copy pathvite.config.ts
File metadata and controls
100 lines (90 loc) · 2.33 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
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
95
96
97
98
99
100
import path from "node:path";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig } from "vite";
// import { compression } from "vite-plugin-compression2";
const host = process.env.TAURI_DEV_HOST;
export default defineConfig(({ mode }) => ({
plugins: [
react(),
tailwindcss(),
mode === "analyze" &&
visualizer({
open: true,
filename: "stats.html",
gzipSize: true,
brotliSize: true,
}),
// compression({
// include: [/\.(js)$/, /\.(css)$/, /\.(html)$/],
// threshold: 1400,
// algorithms: ["brotliCompress"],
// }),
],
clearScreen: false,
server: {
port: 1420,
strictPort: true,
// Tauri 开发时需要显式 host
host: host ?? "localhost",
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
ignored: ["**/src-tauri/**", "**/*.md", "**/*.zmark"],
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
build: {
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) {
if (id.includes("yjs") || id.includes("@hocuspocus")) {
return "vendor-collab";
}
if (id.includes("echarts") || id.includes("zrender")) {
return "vendor-echarts";
}
if (id.includes("katex")) {
return "vendor-katex";
}
if (
id.includes("react") ||
id.includes("react-dom") ||
id.includes("react-router-dom")
) {
return "vendor-react";
}
if (
id.includes("@tiptap") ||
id.includes("tiptap") ||
id.includes("prosemirror")
) {
return "vendor-editor";
}
if (
id.includes("lucide-react") ||
id.includes("clsx") ||
id.includes("tailwind-merge") ||
id.includes("radix-ui")
) {
return "vendor-ui";
}
return "vendor";
}
},
},
},
},
}));