-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
65 lines (62 loc) · 1.83 KB
/
Copy pathvite.config.ts
File metadata and controls
65 lines (62 loc) · 1.83 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath } from 'node:url';
const host = process.env.TAURI_DEV_HOST;
// Port the embedded Rust HTTP server (browser access) listens on.
const WEB_SERVER_PORT = 9870;
export default defineConfig(async () => ({
plugins: [react()],
clearScreen: false,
resolve: {
// Exact-match so the shims' own `@tauri-apps/api` import doesn't recurse.
alias: [
{
find: /^@tauri-apps\/api\/core$/,
replacement: fileURLToPath(new URL('./src/lib/tauri-core.ts', import.meta.url)),
},
{
find: /^@tauri-apps\/api\/event$/,
replacement: fileURLToPath(new URL('./src/lib/tauri-event.ts', import.meta.url)),
},
],
},
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? { protocol: 'ws', host, port: 1421 }
: undefined,
watch: { ignored: ['**/src-tauri/**'] },
// In dev, browsing from a plain browser tab on :1420 proxies IPC/media/events
// to the embedded Rust server so the same UI works with HMR.
proxy: {
'/__ipc': `http://localhost:${WEB_SERVER_PORT}`,
'/__media': `http://localhost:${WEB_SERVER_PORT}`,
'/__events': {
target: `http://localhost:${WEB_SERVER_PORT}`,
changeOrigin: true,
},
},
},
build: {
rollupOptions: {
output: {
manualChunks(id: string) {
if (id.includes('node_modules/react/') || id.includes('node_modules/react-dom/')) {
return 'react-vendor';
}
if (id.includes('@tanstack')) {
return 'tanstack';
}
if (id.includes('zustand')) {
return 'state';
}
if (id.includes('@tauri-apps')) {
return 'tauri';
}
},
},
},
},
}));