-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[HMR] TailwindCSS do not compile new CSS when files with HMR changed #15460
Comments
Start a new pull request in StackBlitz Codeflow. |
I think maybe quite a few people (who use Vite+Vue+TailwindCSS) have encountered this but I couldn't find an issue about it. 😢 |
I'm having an issue with Tailwind also. I can't upgrade past Vite 4.5.1 because hot module reload causes the page to full reload every time I change CSS classes. I tried to isolate the problem by creating a new repo, but it works as expected. I also copied half my project into the new repo and it still worked properly. I also tried a strange idea of copying the affected repo to another folder and running it. That one exhibits the problem also. I see this in the terminal every time I change CSS class and see full page reload:
Currently frustrated because it works fine with v4.5.1 but i can't upgrade vite past that. I've spent a lot of time messing with packages but I can't get it working in this project.
|
I debugged and found these: When a Vue file is modified, because it is self-accepting, and it has https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/hmr.ts#L288-L293 However, it does nothing effective because |
Hmm, I did
And the app is not running properly. I can't access it. My vite config is on port 3000 but the one that loads is on port 5173 and it doesn't work on that port, probably because it skipped dependency pre-bundling. |
@agm1984 I'm sorry. The command I provided is wrong. It should be And I think maybe you're having a different problem than this issue. It might be better to create a new issue with minimal reproduction. |
@agm1984 That's a different issue and perhaps you're interested in #15118 instead. @KermanX If I move the As to why a full reload didn't happen, I'm not really sure but it could be related to #15229, where we explicitly didn't want a full reload to happen for tailwind for circular imports. I suppose we always expected Tailwind code to exist in their own CSS file for better HMR anyways. |
I think it is reasonable to make HMR work with
I think if HMR is intended to not work with |
Hey 👋 I have just created the #15516 issue when afterwards I noticed yours @KermanX I am using Remix + Vite + Tailwind as tech stack and noticed that in my case, the CSS class actually reaches the browser css file but nothing is applied. Which in your case it seems like the class isnt created at all. |
@Danones I think the two issues are different. My issue is that Vite doesn't trigger a TailwindCSS re-run when putting the In your issue, TailwindCSS re-runs after the file is changed (because you run the TailwindCSS compiler in a new process in watch mode), which I think may be a problem with how Vite (or maybe Remix plugin) handles modified CSS. |
I don't think that return value will fix the issue you're seeing, but it does look strange that the value is ignored. Seems like it's being called to only mutate For a fix, we could:
|
You are right @KermanX and I was aware of that. Just wanted to leave a comment to make aware of a similar issue. I have found what was causing my issue but I am afraid the solution isn't optimal.
seems to fix the issue for now but because I am using this on my company project I will have to wait for this to be more stable in order to move forward |
Describe the bug
TailwindCSS does not compile new CSS when a file is modified and handled by HMR (e.g. a Vue SFC) in dev mode.
The class name of the element is updated by the Vue plugin via HMR, but Tailwind doesn't create a new rule for the new class name. So the new class name becomes useless.
There is a similar issue, which is about pug: #4588
And there is also a relative test (pug only): https://github.com/vitejs/vite-plugin-vue/blob/main/playground/tailwind/__tests__/tailwind.spec.ts.
I think it is an issue of Vite, not plugin-vue. Because this also happens to my web framework and its plugin (with HMR).
Reproduction
https://stackblitz.com/edit/vitejs-vite-8djtq2?file=src%2FApp.vue
Steps to reproduce
install
anddev
App.vue
:text-blue-400
→text-red-400
.text-red-400
rule is not generated.System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: