-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
92 lines (85 loc) · 2.69 KB
/
vite.config.ts
File metadata and controls
92 lines (85 loc) · 2.69 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";
const host = process.env.TAURI_DEV_HOST;
const localDevHost = "127.0.0.1";
const devPort = 1420;
const rootDir = fileURLToPath(new URL(".", import.meta.url));
// https://vite.dev/config/
export default defineConfig(async () => ({
// Serve the app from the repository root so dev can resolve `/src/main.tsx`.
// Static assets still come from `public/`, and Tauri still reads the compiled app from `dist/`.
root: rootDir,
plugins: [react()],
resolve: {
alias: {
"@": resolve(rootDir, "src"),
},
},
build: {
outDir: resolve(rootDir, "dist"),
emptyOutDir: true,
rollupOptions: {
output: {
// Keep chunk boundaries stable as features grow.
manualChunks(id) {
const moduleId = id.replace(/\\/g, "/");
if (moduleId.includes("/node_modules/")) {
if (
moduleId.includes("/react/") ||
moduleId.includes("/react-dom/") ||
moduleId.includes("/scheduler/")
) {
return "vendor-react";
}
if (moduleId.includes("/@tauri-apps/")) {
return "vendor-tauri";
}
return "vendor";
}
if (
moduleId.includes("/src/components/overlay/ConversionModal") ||
moduleId.includes("/src/hooks/ui/app/conversion/") ||
moduleId.includes("/src/constants/convert") ||
moduleId.includes("/src/types/conversion")
) {
return "feature-conversion";
}
if (moduleId.includes("/src/components/preview/QuickPreview")) {
return "feature-preview";
}
if (
moduleId.includes("/src/components/overlay/SettingsOverlay") ||
moduleId.includes("/src/components/settings/")
) {
return "feature-settings";
}
return undefined;
},
},
},
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: devPort,
strictPort: true,
// Use an explicit IPv4 loopback address so Windows does not resolve `localhost` to `::1`.
host: host || localDevHost,
hmr: host
? {
protocol: "ws",
host,
port: devPort,
}
: undefined,
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));