Files
waggle-os/apps/web/vite.config.ts
shumeiko.it 23431550ae build: one tsc -b build and a source export condition (P2.1)
- tsconfig.build.json references the nine in-scope packages; each package
  is composite and references the workspace packages it depends on.
  build:packages is now `tsc -b tsconfig.build.json` instead of a chain
  of cd commands.
- Every in-scope package exports its TypeScript entry under a `source`
  condition next to the dist/ entries. Vitest, tsx (dev:server, the
  Tauri dev launch, the e2e server), the sidecar and launcher bundles and
  the web app resolve it, so none of them needs build:packages first or
  can pick up a stale dist/. The vitest src aliases remain only for the
  excluded packages that have no source export.
- Published packages with a files list (agent, cli, marketplace) pack
  src/ too, so the source condition never points at a missing file.
- tsconfig.tests.json and `npm run typecheck:tests` type-check the test
  suites of the in-scope packages. They report 426 existing errors, so
  the CI step is advisory for now.
- The root test run leaves out the excluded and postponed packages
  (hive-mind-*, memory-mcp, wiki-compiler, team-server, waggle-dance,
  worker, weaver); they are not built either.
- CI runs the test job on Ubuntu, macOS and Windows with Node 22.23.2
  (ADR-0008), and no longer builds the hook runtime and the memory MCP
  server.
2026-10-24 17:14:29 +02:00

59 lines
2.0 KiB
TypeScript

import { defineConfig, defaultClientConditions } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";
// https://vitejs.dev/config/
const sidecarTarget = process.env.SIDECAR_TARGET ?? "http://127.0.0.1:3333";
export default defineConfig(({ mode }) => ({
server: {
host: "::",
port: 8080,
hmr: {
overlay: false,
},
proxy: {
"/api": {
target: sidecarTarget,
changeOrigin: true,
},
"/health": {
target: sidecarTarget,
changeOrigin: true,
},
"/ws": {
target: sidecarTarget.replace(/^http/, "ws"),
ws: true,
},
},
},
plugins: [react(), mode === "development" && componentTagger()].filter(Boolean),
build: {
rollupOptions: {
output: {
// Split the heaviest independent vendor libraries out of the single
// ~1.9MB app chunk so they cache separately and don't gate first paint.
// The React runtime + router stay in ONE chunk so context/singleton
// init order can't break across a chunk boundary.
manualChunks(id: string) {
if (!id.includes("node_modules")) return;
if (id.includes("framer-motion")) return "vendor-motion";
if (id.includes("recharts") || id.includes("d3-") || id.includes("victory-")) return "vendor-charts";
if (id.includes("@radix-ui")) return "vendor-radix";
if (/[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|scheduler)[\\/]/.test(id)) return "vendor-react";
},
},
},
},
resolve: {
// Workspace packages (@waggle/shared) resolve to src/ through their
// `source` export, so the UI builds without build:packages (P2.1).
conditions: ["source", ...defaultClientConditions],
alias: {
"@": path.resolve(__dirname, "./src"),
},
dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
},
}));