vite.config.ts 878 B

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