Now that Tailwind is in full JIT mode, the purge config is replaced by a content config. This way Tailwind can watch your layouts and generated the necessary classes.
It would be ideal to have it read the hugo_stats.json file but I can’t find a way.
Previously with Tailwind 2: under the purge key of `tailwind.config.js``
Personally, after far too many occasions wondering why styles aren’t present in production environments, I avoid string concatentation for classes altogether now even though I’m now using Tailwind 3 in JIT mode, so it’ no longer an issue anyway.
Only thing I can think of is that maybe your postcss process is running before hugo_stats is written to disk?
Thanks. I’m using that, but unfortunately it’s not 100% working this way. More complicated rules like [&:checked~header_nav]:bg-red-100 are ignored. Therefore my search for an alternative approach.
But I’m starting to think it’s a ultimately a Tailwind issue, as I can’t get such rules to be picked up with a custom extractor as well.
I’ve finally seem to have figured out how the extractor works (line oriented) and found the issue: Hugo uses unicode notation for the & in the selector, but Tailwind doesn’t like it.
For me, that would be the least practical. Too much mental load. Even more so for the next guy. Better to fall back to writing css directly in a separate file.
But both approaches defeat one of the selling points of Tailwind where everything related should be accessible in one place (granted sometimes there can be a bit bloat this way).
Anyway, thanks for caring. Awesome job with Hugo. Love it!
If you write rules like [&:checked~header_nav]:bg-red-100 a lot, then sure.
I have worked with some largish Tailwind 3.x sites using the hugo_stats.json as the main source of truth, and with just a handful of whitelist additions it works reallly well.