/// <reference types="vitest/config" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import wails from "@wailsio/runtime/plugins/vite";
import path from "node:path";

export default defineConfig({
  // wails3 dev 传 WAILS_VITE_PORT(默认 9245);浏览器预览(纯 vite)回退 5173。
  server: {
    port: Number(process.env.WAILS_VITE_PORT) || 5173,
    strictPort: !!process.env.WAILS_VITE_PORT,
  },
  plugins: [react(), wails("./bindings")],
  resolve: {
    alias: { "@": path.resolve(__dirname, "./src") },
  },
  // 单元/组件测试：纯逻辑 + 关键组件（jsdom 环境）。运行：npm test
  test: {
    environment: "jsdom",
    globals: true,
    setupFiles: ["./src/test/setup.ts"],
    include: ["src/**/*.{test,spec}.{ts,tsx}"],
  },
});
