fix: pin Tailwind source so SSR and client CSS hashes match #29

Merged
ronnyandre merged 1 commit from fix/ssr-css-hash-mismatch into main 2026-11-16 23:12:20 +01:00
Owner

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 references styles-BhdOp6Gw.css, which exists, and React swaps that href in on hydration. Until then the page is unstyled.

Cause

.dockerignore strips .gitignore from 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 .gitignore is present, so both builds agree and the bug can't be seen.

Reproduced by building a git archive copy with .gitignore removed: the SSR bundle referenced styles-DBFzi11z.css, the exact broken hash on the live site.

Fix

@import 'tailwindcss' source('.') in src/styles.css: scan only src/, independent of .gitignore. Also added a note on this to CLAUDE.md.

Verification

  • Build without .gitignore (container-shaped): SSR and public/ both use styles-Cm11z-fJ.css
  • Local build: same file, same hash
  • The CSS shrank by about 700 bytes. All 7 dropped rules (border-collapse, contents, max-md:min-h-10, running, static, transform, zoom-in) were false matches from docs, factory/ reports, the lockfile and nixpacks.toml. None are used in src/.

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

## 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 references `styles-BhdOp6Gw.css`, which exists, and React swaps that href in on hydration. Until then the page is unstyled. ## Cause `.dockerignore` strips `.gitignore` from 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 `.gitignore` is present, so both builds agree and the bug can't be seen. Reproduced by building a `git archive` copy with `.gitignore` removed: the SSR bundle referenced `styles-DBFzi11z.css`, the exact broken hash on the live site. ## Fix `@import 'tailwindcss' source('.')` in `src/styles.css`: scan only `src/`, independent of `.gitignore`. Also added a note on this to CLAUDE.md. ## Verification - Build without `.gitignore` (container-shaped): SSR and `public/` both use `styles-Cm11z-fJ.css` - Local build: same file, same hash - The CSS shrank by about 700 bytes. All 7 dropped rules (`border-collapse`, `contents`, `max-md:min-h-10`, `running`, `static`, `transform`, `zoom-in`) were false matches from docs, `factory/` reports, the lockfile and `nixpacks.toml`. None are used in `src/`. 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](https://claude.com/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]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!29
No description provided.