The Tailwind CSS “JIT Mode” Bug That Only Happens in Production

In fairness, Adam Wathan & Steve Schoger tried to warn me about this feature of Tailwind CSS’s “Just-in-Time” engine, but I still only caught this bug by accident. Don’t make my mistake!

Dr. Derek Austin 🥳
Coding at Dawn
Published in
5 min readJul 31, 2021

--

Photo by Jill Heyer on Unsplash

Can you spot the bug in this React .jsx code using Tailwind CSS? 🐞

View raw code as a GitHub Gist

The bug is an easy mistake to make, and it’s sneaky to detect, too.

The issue is that I’m generating dynamic strings to use for my CSS classes, and that is going to break Tailwind, for reasons I’ll explain shortly.

Plus, if I have another h-5 or w-5 somewhere in my local hot reloading cache, then I might see different behavior in production vs. development.

Here’s what that would look like using social SVG icons taken from SimpleIcons.org, a free repository of brand logos in SVG format:

--

--

Dr. Derek Austin 🥳
Coding at Dawn

Career advice, film reviews, writing tips, and coding with JS / TS, React & Git. Bio: Web dev since '05. BS & MS in Bioinformatics. Doctor of Physical Therapy.