-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
68 lines (59 loc) · 1.58 KB
/
Copy pathvite.config.ts
File metadata and controls
68 lines (59 loc) · 1.58 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
import path from "node:path";
import { defineConfig, type Plugin } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
const JASSUB_DEFAULT_FONT_URL = "new URL('./default.woff2', import.meta.url)";
const JASSUB_DEFAULT_FONT_URL_IGNORED =
"new URL(/* @vite-ignore */ './default.woff2', import.meta.url)";
export function viteIgnoreMissingJassubDefaultFont(): Plugin {
return {
name: "vite-ignore-missing-jassub-default-font",
enforce: "pre",
transform(code, id) {
if (
!id.includes("node_modules") ||
!id.includes("jassub") ||
!code.includes(JASSUB_DEFAULT_FONT_URL)
) {
return null;
}
return code.replaceAll(
JASSUB_DEFAULT_FONT_URL,
JASSUB_DEFAULT_FONT_URL_IGNORED,
);
},
};
}
export default defineConfig(async () => ({
plugins: [viteIgnoreMissingJassubDefaultFont(), react(), tailwindcss()],
worker: {
format: "es",
},
optimizeDeps: {
include: ["jassub"],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// Rust 后端由 cargo watch 处理;Python venv 文件极多,会耗尽 inotify 配额
ignored: ["**/src-tauri/**", "**/.venv/**", "**/venv/**"],
},
},
}));