vite.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // 多入口构建:主窗口 (index.html) + URL 批量导入窗口 (import.html)
  10. build: {
  11. rollupOptions: {
  12. input: {
  13. main: "index.html",
  14. import: "import.html",
  15. },
  16. },
  17. },
  18. // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  19. //
  20. // 1. prevent Vite from obscuring rust errors
  21. clearScreen: false,
  22. // 2. tauri expects a fixed port, fail if that port is not available
  23. server: {
  24. port: 1420,
  25. strictPort: true,
  26. host: host || false,
  27. hmr: host
  28. ? {
  29. protocol: "ws",
  30. host,
  31. port: 1421,
  32. }
  33. : undefined,
  34. watch: {
  35. // 3. tell Vite to ignore watching `src-tauri`
  36. ignored: ["**/src-tauri/**"],
  37. },
  38. },
  39. }));