import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; // On mobile, the dev server has to be reachable from the phone/emulator rather // than only from localhost. `tauri android dev` sets TAURI_DEV_HOST to the // address the device should dial; when it's absent (desktop) we keep the // localhost-only default. const devHost = process.env.TAURI_DEV_HOST; // Vite config tuned for Tauri: fixed port, no clearing the terminal Tauri owns. export default defineConfig({ plugins: [react()], clearScreen: false, server: { port: 1420, strictPort: true, host: devHost || false, // HMR must also point at the reachable address, or the device loads the app // but can never connect back for updates. hmr: devHost ? { protocol: "ws", host: devHost, port: 1421 } : undefined, watch: { // Don't watch the Rust side; Tauri handles that. ignored: ["**/src-tauri/**"], }, }, });