import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; // Use TAURI_DEV_HOST when running inside tauri dev, otherwise fall back to localhost. const host = process.env.TAURI_DEV_HOST; export default defineConfig({ plugins: [react()], // Prevent vite from obscuring Rust errors in tauri dev clearScreen: false, server: { port: 5173, strictPort: true, host: host || false, hmr: host ? { protocol: 'ws', host, port: 5174 } : undefined, watch: { // Tauri expects a hot reloading mechanism; ignore Rust src changes in Vite ignored: ['**/src-tauri/**'], }, }, build: { outDir: 'dist', emptyOutDir: true, // Produces smaller bundle sizes compatible with Tauri's webview target: ['es2021', 'chrome105', 'safari13'], minify: !process.env.TAURI_DEBUG ? 'esbuild' : false, sourcemap: !!process.env.TAURI_DEBUG, }, });