33 lines 818 B
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
import { defineConfig } from class="c-str">"vite";
import react from class="c-str">"@vitejs/plugin-react";
class=class="c-str">"c-com">// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
class=class="c-str">"c-com">// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [react()],
class=class="c-str">"c-com">// Vite options tailored for Tauri development and only applied in class="c-str">`tauri dev` or class="c-str">`tauri build`
class=class="c-str">"c-com">//
class=class="c-str">"c-com">// class="c-num">1. prevent Vite from obscuring rust errors
clearScreen: false,
class=class="c-str">"c-com">// class="c-num">2. tauri expects a fixed port, fail if that port is not available
server: {
port: class="c-num">1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: class="c-str">"ws",
host,
port: class="c-num">1421,
}
: undefined,
watch: {
class=class="c-str">"c-com">// class="c-num">3. tell Vite to ignore watching class="c-str">`src-tauri`
ignored: [class="c-str">"**/src-tauri/**"],
},
},
}));