Chat on WhatsApp

A Tailwind class works locally but disappears on production, why?

Categories: Hyvä Bug Fixing

It was purged. Tailwind only keeps classes it can find by scanning the files listed in your tailwind.config.js content array. If a class is built dynamically in PHP, lives in a PHTML the scanner doesn’t cover, or is concatenated from strings, Tailwind never sees it and strips it from the production bundle. The fix is to add the path to content, safelist the class, or rebuild the class statically, then rebuild Tailwind. We catch these by diffing the DOM classes against the compiled app.css.

Was this helpful?