Babel plugin / require cache on css import? (stale tailwind config / css)


Just a heads up for people using tailwind with babel plugin macros (as per Tailwindcss with babel-macro-plugin and CSS-in-JS - #38 by jeffceriello)

It seems config / css output is getting cached somewhere

I make changes to tailwind.config.js (adding some responsive utilities for my global styles) and build my tailwind.css to index.css

I then import the index.css into my theme as a Global style

I’m also using twin.macro which I guess is also creating its own versions of my utility classes because I use eg

For some reason, any changes to the tailwind config / built css don’t update on the front end. Even after a complete rebuild. The index.css itself has the new values, but when I run my site it’s getting old values for the css in server.js

I tried deleting my build folder. I tried rebuilding my css. Deleted my app data in my browser. Ran in incognito. I restarted VS Code etc. I restarted Wamp

Eventually something updated it, but I’m not sure what.

Again what’s odd is the index.css is updated fine but it’s not getting updated into server.js correctly .
I’m wondering If this is more an issue with Frontity’s style import rather than tailwind specifically

I guess I can try with a basic index.css etc file, skipping the tailwind part, and see if it still happens

Any advice appreciated


I think it might be this

Appears to be a Babel caching issue

Not sure specific fix. Probably deleting .cache/babel-loader or .cache/@babel/register from node_modules

Will do some investigation

After building the CSS from tailwindcss, did you also rebuild Frontity itself? Otherwise the CSS-in-JS won’t work.

In my project I run tailwind in the theme and load it “normally” from HTML (link element in the ). This works way better with Frontity and tailwind because it can’t be split properly per component.

Yes rebuilt everything. Restarted VS Code. Re-ran npm run build:css and npm run dev

Almost entirely sure it’s the Babel cache as stated on that twin.macro GitHub

Aside from the cache issue, you’re saying just embed the index.css in my html and not import it into my js and then just use className=“my-class” ?

I’m not actually sure what importing it actually does anyway.

Either way I also need to properly separate what’s going in my index.css (mainly tailwind base and @screen stuff) and what I’m using through tw since it’s probably duplicating at the moment