Files
Arah2/web/vite.config.ts
T
araharah-executor 8b39ea70c3 feat(03-04): Worker [assets] binding + one-command deploy + D-14 build-artifact gate
- wrangler.jsonc assets block serves ../web/dist; run_worker_first keeps /api/* + /telegram/* on the Worker (D-13)
- root npm run deploy = build theme → web → bot wrangler deploy + set-webhook (D-15); dev = build + wrangler dev --port 8787 --local (D-12)
- vite.config.ts dual-build: __ARAHARAH_HARNESS__ define keyed on --mode harness, separate dist/dist-harness outDirs
- main.ts guard unchanged; ambient constant declared once in web/src/vite-env.d.ts
- build-artifact.test.mjs BA1..BA6: zero CDN refs, self-hosted fonts, MapLibre worker, inlined style, no mock installer in ANY emitted file (HTML included)
2026-10-23 00:15:26 +08:00

37 lines
1.3 KiB
TypeScript

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,
},
};
});