import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import { fileURLToPath } from "node:url"; const hmrClientPort = Number(process.env.VITE_HMR_CLIENT_PORT || ""); const defaultDevApiProxyTarget = hmrClientPort ? "http://backend:8000" : "http://127.0.0.1:8000"; const devApiProxyTarget = process.env.VITE_DEV_API_PROXY_TARGET || defaultDevApiProxyTarget; const tauriDevHost = process.env.TAURI_DEV_HOST; const tauriPlatform = process.env.TAURI_ENV_PLATFORM; const tauriDebug = process.env.TAURI_ENV_DEBUG === "true"; export default defineConfig({ clearScreen: false, envPrefix: ["VITE_", "TAURI_ENV_"], plugins: [vue()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, server: { host: tauriDevHost || true, port: 5173, strictPort: true, hmr: hmrClientPort ? { clientPort: hmrClientPort } : undefined, watch: { ignored: ["**/src-tauri/**"], }, proxy: { "/api": { target: devApiProxyTarget, changeOrigin: true, }, }, }, build: { target: tauriPlatform === "windows" ? "chrome105" : "safari13", minify: tauriDebug ? false : "esbuild", sourcemap: tauriDebug, }, });