| 1 | import { svelte } from "@sveltejs/vite-plugin-svelte"; |
| 2 | import { internalIpV4Sync } from "internal-ip"; |
| 3 | import { defineConfig } from "vite"; |
| 4 | |
| 5 | const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM); |
| 6 | |
| 7 | // https://vitejs.dev/config/ |
| 8 | export default defineConfig({ |
| 9 | plugins: [svelte()], |
| 10 | |
| 11 | // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` |
| 12 | // prevent vite from obscuring rust errors |
| 13 | clearScreen: false, |
| 14 | // tauri expects a fixed port, fail if that port is not available |
| 15 | server: { |
| 16 | host: mobile ? "0.0.0.0" : false, |
| 17 | port: 1420, |
| 18 | strictPort: true, |
| 19 | hmr: mobile |
| 20 | ? { |
| 21 | protocol: "ws", |
| 22 | host: internalIpV4Sync(), |
| 23 | port: 1421, |
| 24 | } |
| 25 | : undefined, |
| 26 | }, |
| 27 | }); |