import { defineConfig } from "vite"; export default defineConfig(({ mode }) => { const isHarness = mode === "harness"; return { base: "/", // 03-04 dual-build contract (the capture-harness fix, T-03-21): // `vite build --mode harness` emits to dist-harness/ WITH the mock // installer + fetch stubs; every other build emits to dist/ WITHOUT // them. The constant is REAL only in the harness mode and statically // false everywhere else — including plain `vite dev`, where this // define keeps main.ts's ambient reference from throwing a // ReferenceError while the fallback mock still fires via // import.meta.env.DEV. // // Vite replaces the IDENTIFIER textually at build time, so the // harness bundle compiles `if (VITE_HARNESS) installMockWebApp()` // down to `if (true) …`. The production build never defines it, // so the identifier is unreferenced and the branch is tree-shaken. // // The two builds must NEVER share an outDir: sharing one would make // them clobber each other and make the BA5 gate meaningless. define: { __ARAHARAH_HARNESS__: JSON.stringify(isHarness), }, build: { outDir: isHarness ? "dist-harness" : "dist", emptyOutDir: true, target: "es2022", }, server: { port: 5173, strictPort: true, }, }; });