fix: pin Tailwind source so SSR and client CSS hashes match #29
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ssr-css-hash-mismatch"
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?
Problem
On fliary.com the page briefly paints with no CSS. The server-rendered HTML links
/assets/styles-DBFzi11z.css, which is a 404. The client bundle referencesstyles-BhdOp6Gw.css, which exists, and React swaps that href in on hydration. Until then the page is unstyled.Cause
.dockerignorestrips.gitignorefrom the build context. Tailwind v4's automatic source detection relies on.gitignore, so in the container the SSR build also scanned the client build's fresh.output/. It found extra candidate class names and hashed a different CSS file, which it links but never emits. Locally.gitignoreis present, so both builds agree and the bug can't be seen.Reproduced by building a
git archivecopy with.gitignoreremoved: the SSR bundle referencedstyles-DBFzi11z.css, the exact broken hash on the live site.Fix
@import 'tailwindcss' source('.')insrc/styles.css: scan onlysrc/, independent of.gitignore. Also added a note on this to CLAUDE.md.Verification
.gitignore(container-shaped): SSR andpublic/both usestyles-Cm11z-fJ.cssborder-collapse,contents,max-md:min-h-10,running,static,transform,zoom-in) were false matches from docs,factory/reports, the lockfile andnixpacks.toml. None are used insrc/.After deploy, Cloudflare may serve cached HTML pointing at the missing file for up to 4h. Purge the cache if the flash persists.
🤖 Generated with Claude Code
.dockerignore strips .gitignore from the build context, so in the container Tailwind's automatic source detection also scanned the client build's fresh .output/. The SSR pass then hashed a different CSS file than the one shipped to public/, and the server HTML linked a 404 stylesheet: the page painted unstyled until hydration swapped in the client's href. Scan only src/ via `@import 'tailwindcss' source('.')`. Verified with a .gitignore-less build: SSR and public/ now both reference the same file. Co-Authored-By: Claude Opus 5.5 <[email protected]>