/ vite.config.js
vite.config.js
 1  import { defineConfig } from "vite";
 2  import { sveltekit } from "@sveltejs/kit/vite";
 3  
 4  // @ts-expect-error process is a nodejs global
 5  const host = process.env.TAURI_DEV_HOST;
 6  
 7  // https://vitejs.dev/config/
 8  export default defineConfig(async () => ({
 9    plugins: [sveltekit()],
10  
11    // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
12    //
13    // 1. prevent vite from obscuring rust errors
14    clearScreen: false,
15    // 2. tauri expects a fixed port, fail if that port is not available
16    server: {
17      port: 1420,
18      strictPort: true,
19      host: host || false,
20      hmr: host
21        ? {
22            protocol: "ws",
23            host,
24            port: 1421,
25          }
26        : undefined,
27      watch: {
28        // 3. tell vite to ignore watching `src-tauri`
29        ignored: ["**/src-tauri/**"],
30      },
31    },
32  }));