From f5e15c8d65d1c7b16000d6f93e0ff49c2260caf6 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Thu, 18 Jun 2026 09:26:53 +0800 Subject: [PATCH] fix(docs): merge batch assets in combine job to fix client-side routing 404 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Symptom: clicking a formula on /browse/ changed the URL but showed 404; refreshing the page loaded it correctly. This is classic client-side routing failure — Vue Router fetches the route's JS chunk, the chunk 404s, the route can't render. Root cause: each build-batch job in docs.yml runs a separate VitePress build, and VitePress produces different content-hashed JS chunks per build because the page set differs (9 batches → 9 distinct app.HASH.js files, plus dist-main's own hash). The combine job only deployed dist-main's assets/, but browse HTML from each batch references batch-specific asset hashes — so every batch's browse pages referenced chunks that weren't deployed. Verified by downloading artifacts from run 27699130632: dist-main had app.CUFvjMGd.js, batches 0-8 had 9 different hashes (tggRrD32, lhlnUi-u, wADyZrW9, NxYOTzkh, TU-EUwTC, j-JEY3xz, Bh3mvEjZ, Sac3zhiF, BldWXoD6). None matched. Fix: also cp -r each batch's assets/ into dist/assets/ during the combine step. Content-hashing guarantees no filename conflicts (same content → same filename; different content → different filename). Total added payload is ~9 small duplicate-ish app chunks (~few KB each), acceptable for a static site. --- .github/workflows/docs.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e23c2245..a3f9c6be 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -249,7 +249,13 @@ jobs: pattern: dist-batch-* path: batches - - name: Merge batch browse pages + - name: Merge batch browse pages and assets + # Each batch's VitePress build produces its own content-hashed JS chunks + # (app.HASH.js, browse_index.md.HASH.lean.js, etc.) because the page set + # differs per batch. Browse HTML from batch N references batch-N's hashes, + # so we must merge ALL batches' assets/ into dist/assets/ — otherwise + # client-side navigation 404s on the missing chunks (the SSR HTML still + # works on full page refresh, which masked this for a long time). run: | for d in batches/dist-batch-*/; do [ -d "$d" ] || continue @@ -258,6 +264,10 @@ jobs: mkdir -p dist/browse cp -r "$d/browse/"* dist/browse/ 2>/dev/null || true fi + if [ -d "$d/assets" ]; then + mkdir -p dist/assets + cp -r "$d/assets/"* dist/assets/ 2>/dev/null || true + fi done shell: bash