This repository has been archived on 2026-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
orchestrator/agent-team/web/vite.config.ts
Adam Moussa 3f4b95579e perf+a11y(agent-team): split vendor bundle + GPT-4.1 review fixes
GPT-4.1 cross-family review verdict: SHIP-WITH-FIXES, no BLOCKs (read-only,
XSS-safe, no-backend, gate-vs-inert all confirmed). Applied:
- a11y: aria-label on the Board/Pipeline Tabs; drawer collapsible section labels
  are now semantic <h3> headings.
- Bundle: function-based rollup manualChunks splits react/flow/markdown/radix/
  vendor so the 614 kB single chunk is gone (largest now ~142 kB react); app
  code drops to ~30 kB. Clears the 500 kB Vite warning. CSS splits too.

(Skipped GPT's .prose-sm finding — incorrect; index.css uses a hand-written .md
block, not Tailwind Typography. Roving-tabindex left out by design for this
read-only view.)

Typecheck + 36 tests + build all green.
2026-06-24 14:04:38 -04:00

66 lines
2.2 KiB
TypeScript

/// <reference types="vitest/config" />
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,
},
});