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)
This commit is contained in:
+34
-21
@@ -1,23 +1,36 @@
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig(({ mode }) => ({
|
||||
base: "/",
|
||||
// 03-03: the harness constant (declared ambient in main.ts; canonical home
|
||||
// is web/src/vite-env.d.ts under plan 03-04) is REAL only in --mode harness
|
||||
// builds and statically false everywhere else — with a bare ambient global
|
||||
// referenced in main.ts, this define keeps plain `vite dev` from throwing a
|
||||
// ReferenceError while the fallback mock install there still fires via
|
||||
// import.meta.env.DEV. 03-04's dual-build config keys on the same mode.
|
||||
define: {
|
||||
__ARAHARAH_HARNESS__: JSON.stringify(mode === "harness"),
|
||||
},
|
||||
build: {
|
||||
outDir: "dist",
|
||||
emptyOutDir: true,
|
||||
target: "es2022",
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
},
|
||||
}));
|
||||
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,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user