/// import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; // The SPA is served by the FastAPI dashboard (agent_team/dashboard.py) from // web/dist at LAN :8770. In dev, proxy /api to a locally running dashboard so // `npm run dev` talks to real data without CORS. No CDN — everything bundles // locally (the dashboard is offline/LAN-only). export default defineConfig({ plugins: [react()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, build: { outDir: "dist", emptyOutDir: true, sourcemap: false, rollupOptions: { output: { // Split heavy vendors into their own chunks so the app/UI code isn't // re-downloaded when only a component changes, and to clear the 500 kB // single-chunk warning. Function form (not object) so react-dom and // transitive deps bucket precisely instead of collapsing into a stub. manualChunks(id) { if (!id.includes("node_modules")) return; if (/[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/.test(id)) return "react"; if (id.includes("reactflow") || id.includes("dagre")) return "flow"; if (id.includes("@radix-ui")) return "radix"; if ( id.includes("react-markdown") || id.includes("micromark") || id.includes("mdast") || id.includes("hast") || id.includes("unist") || id.includes("unified") || id.includes("remark") || id.includes("vfile") || id.includes("property-information") || id.includes("/decode-named-character-reference/") || id.includes("character-entities") ) return "markdown"; return "vendor"; }, }, }, }, server: { proxy: { "/api": { target: process.env.AGENT_TEAM_DASH || "http://127.0.0.1:8770", changeOrigin: true, }, }, }, test: { globals: true, environment: "jsdom", setupFiles: ["./src/test/setup.ts"], css: false, // Unit tests live under src/. Scope vitest there so it does NOT pick up the // Playwright e2e specs in e2e/ (they import @playwright/test — the Playwright // runner, not vitest — and fail to load under `vitest run`). include: ["src/**/*.{test,spec}.{ts,tsx}"], }, });