vite.config.ts 756 B

123456789101112131415161718192021222324252627282930
  1. import { defineConfig } from "vite";
  2. // @ts-expect-error process is a nodejs global
  3. const host = process.env.TAURI_DEV_HOST;
  4. // https://vitejs.dev/config/
  5. export default defineConfig(async () => ({
  6. // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  7. //
  8. // 1. prevent vite from obscuring rust errors
  9. clearScreen: false,
  10. // 2. tauri expects a fixed port, fail if that port is not available
  11. server: {
  12. port: 1420,
  13. strictPort: true,
  14. host: host || false,
  15. hmr: host
  16. ? {
  17. protocol: "ws",
  18. host,
  19. port: 1421,
  20. }
  21. : undefined,
  22. watch: {
  23. // 3. tell vite to ignore watching `src-tauri`
  24. ignored: ["**/src-tauri/**"],
  25. },
  26. },
  27. }));