-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] TailwindCSS JIT requires a restart every time a new class is inferred #3246
Comments
Also, please see the |
Hello @aaronjensen. I just noticed your discussion with @drwpow in #2916 then followed through here. For tailwind users this is a hot topic! I have now spend many hours looking into what is actually going on here. Because Snowpack is such a solid concept I decided to persist, so can contribute here. I hope this will also help the Snowpack authors to accommodate whatever is needed to make the tailwind developer experience exemplary :) 1. Triggering Snowpack to rebuild the CSSThe reason that you need to restart snowpack to see the tailwind changes is that when you change for example a color in tailwind.config.js, snowpack has no idea that it needs to rebuild global.css. This bit is cover-able with a plugin that would mark global.css as when you edit tailwind.config.js. See markChanged() in the plugin API for more details. 2. The real challenge: cache bustingHowever this is not where the challenge lies... After some digging it seems that even if you mark global.css as changed in a custom plugin, snowpack is very good at caching and will check to see if global.css file has changed before it triggers the file for rebuild... As you don't edit that file, its just used as an intermediary file by tailwind via the postcss chain, it won't bust the cache until it changes. A highly annoying workaround is to add a CSS comment and every time you want to rebuild tailwind, just add a letter. Not a pleasant experience by any account but does prevent having to restart snowpack. 3.
|
Just clarifying one thing here:
I am not talking about changing As an aside, we are in the process of migrating to Vite for our projects where this works out of the box, so unless something goes wrong in that migration I probably won't have much time to update this issue, but I do still hope it gets fixed for all the other Snowpack + Tailwind users. |
@aaronjensen thanks for the clarification. I suspect that your issue is still due to snowpack thinking that global.css is never changed so will never rebuild your tailwind CSS via postcss. |
Thanks again for raising this, and taking the time to write up an issue and a great reproduction. I’m happy to announce that we will fix this in the upcoming Please give it a try and let me know if it fixes your problem! |
Nice! Unfortunately I can't try it because I'm still blocked by #3082 (comment) |
Excited to see this @drwpow. Will give it a test on |
Thanks so much @drwpow! DOUBLE EDIT: I ended up having to disable the jit for now, @valtism below is correct. A hard refresh is necessary for me.
|
I was not able to get this working, and like before it only seems to update on a snowpack restart. I have followed the instructions on the Tailwind setup guide, so I don't know what is wrong. This is the repo I was trying to get it to work with: https://github.com/valtism/react-snowpack Edit: Thought it may have been caused because |
I've tested 3.5.0 with static html and the standard tailwind utility workflow. Both tailwind standard mode and JIT mode worked without any issue. |
The JIT kinda works for me. I still have to refresh the page if console is opened or hard refresh to see the changes. |
Ah, I see the issue. It is updating the CSS, but does not update until there is a refresh with the cache disabled / hard refresh. I would like for this to work without refreshing, and ideally with React Fast Refresh. |
It turns out I was mistaken earlier (or something changed in my configuration) --- the webpage does not update until I do a hard refresh, like @BogdanDarius mentioned (refreshing with the console open does not work for me on Firefox Developer Edition). |
Yeah, same here. It still requires a hard refresh for the new classes to load. |
Disabling JIT seems to fix the issue. But this shouldn't be happening ? |
I'm experiencing the same issues listed above. Restarting snowpack causes new classes to load, but changing the classes causes them to disappear. Running latest snowpack, tailwind, and postcss. |
For what it's worth, I ultimately decided to switch to Vite. Snowpack has clearly fallen to the wayside, and Fred himself suggested Snowpack users consider the switch: https://dev.to/fredkschott/5-things-i-learned-while-building-snowpack-to-20-000-stars-b9d https://dev.to/fredkschott/5-more-things-i-learned-building-snowpack-to-20-000-stars-5dc9 |
So snowpack is now abandoned 😶
…On Fri, 17 Dec, 2021, 8:04 pm Francis Lavoie, ***@***.***> wrote:
For what it's worth, I ultimately decided to switch to Vite. Snowpack has
clearly fallen to the wayside, and Fred himself suggested Snowpack users
consider the switch:
https://dev.to/fredkschott/5-things-i-learned-while-building-snowpack-to-20-000-stars-b9d
https://dev.to/fredkschott/5-more-things-i-learned-building-snowpack-to-20-000-stars-5dc9
—
Reply to this email directly, view it on GitHub
<#3246 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFVA4NQQXID3GBV7Q47ELXLURNDATANCNFSM4347W7NA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Seems to be. Only 4 commits since the last release in August. |
Oh noes, that makes me quite frustrated 😞. I've looked at Vite.js and don't see how would I replace Snowpack with it. All I need is fast unbundled frontend build tool with watch. I work with Blazor and thus compile and run server with .NET runtime from DLLs. Which means I just need it to transform static files, basically throw couple Vite requires |
Would you mind commenting on how you achieved this? And does this still work on the latest version (3.8.8)? |
Bug Report Quick Checklist
Describe the bug
Tailwind JIT works by scanning your source files for classes and including them in the css that's built. When used with Snowpack and following the documentation, you must restart Snowpack every time you use a new class, which makes JIT near unusable.
This plugin helps: https://github.com/jadex/snowpack-plugin-tailwindcss-jit
To Reproduce
https://github.com/aaronjensen/snowpack-tailwind-jit-repro
The text was updated successfully, but these errors were encountered: