import { defineConfig } from 'vite'; import { svelte } from '@sveltejs/vite-plugin-svelte'; const host = process.env.TAURI_DEV_HOST; // https://vitejs.dev/config/ export default defineConfig(async () => ({ plugins: [svelte()], // Tauri expects a fixed port and fails if it is not available. clearScreen: false, server: { port: 1420, strictPort: true, host: host || false, hmr: host ? { protocol: 'ws', host, port: 1421, } : undefined, watch: { // Don't watch the Rust backend; tauri handles that. ignored: ['**/src-tauri/**'], }, }, // Produce smaller, debuggable bundles depending on the Tauri build profile. envPrefix: ['VITE_', 'TAURI_'], build: { target: process.env.TAURI_ENV_PLATFORM === 'windows' ? 'chrome105' : 'safari13', minify: !process.env.TAURI_ENV_DEBUG ? 'esbuild' : false, sourcemap: !!process.env.TAURI_ENV_DEBUG, }, }));