fix(webapp): ship the web fonts, and fail the build when a url() dangles (#891) #892
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/891-web-fonts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #891.
The production frontend image has shipped no web fonts since lane 0. Every
.woff2request got nginx's SPA fallback, i.e.index.htmlwith a 200. So the app, dev and prod included, rendered in the browser's fallback sans.Root cause
The problem is how Vite 8 and
@tailwindcss/postcss4.3 interact:@imported fromsrc/ui/index.css, inside Tailwind's pipeline.src/index.css../files/*.woff2againstsrc/, found nothing, and left the urls dangling.I confirmed this with a probe plugin: node origins change from
node_modules/@fontsource-variable/...tosrc/index.cssafter Tailwind, and removing Tailwind emits the fonts.Fix
src/ui/fonts.jsimports the three fontsource sheets from JS, inmain.jsxbeforeindex.css. Each becomes its own CSS module outside Tailwind, so Vite resolves the urls properly. All 21 font files are emitted with hashed names.assetsInlineLimit, so it was inlined asdata:font/woff2, whichfont-src 'self'blocks.vite.config.jsnow never inlines fonts, and other assets keep the default.scripts/check-dist-urls.mjs, runs as part ofnpm run build, and so in CI and the Dockerfile. Everyurl()indist/**/*.cssmust resolve to a file indist/. Remote URLs and inlined fonts fail.location /assets/ { try_files $uri =404; }, so a missing asset is a real 404, notindex.html. It adds noadd_header, so the security headers are still inherited.Verified in a real frontend-prod image
font/woff2and awOF2body./assets/nope.woff2returns 404./campaigns/abc/wikistill returns index.html.Checks
changelog.d/fragment.Follow-ups, not changed here:
/assets/could get immutable cache headers.🤖 Generated with Claude Code