Fixing Tailwind classes that vanish in Astro static builds
Classes worked in dev but disappeared in production. The cause was content-path scanning — here's the diagnosis and the fix.
Dummy content — placeholder for a real post.
The problem
Everything looked right in astro dev, but after astro build a handful of utility classes were simply gone from the production CSS.
Root cause
Tailwind only generates classes it can find by scanning the files listed in content. Classes built dynamically — or living in files outside the configured globs — never make it into the output.
The fix
- Widen the
contentglobs intailwind.configto cover every file that emits classes. - Avoid constructing class names from string fragments; write them in full so the scanner can see them.
- Re-run the production build and diff the output CSS to confirm the classes return.
Takeaway
“Works in dev, breaks in build” almost always points at a build-time scan or tree-shake step — not at the browser.