-
Notifications
You must be signed in to change notification settings - Fork 84
CSS doesn't rebuild when .vue files change #153
Comments
|
Sorry, had it marked as private by mistake. Should be good now 👍🏻 |
@adamwathan I'm having the same issue (#149). There is a |
@hivokas How did you solve it in the end? |
Slowly migrating the project to Vue 3 :) |
Same problem here, stackblitz for reproduction: |
It's my temporary solution. (tested only with TailwindCSS) Open const TAILWIND_PATH = '???'
const tailwindFile = [...mainModule.importers].find((file) => file.url === TAILWIND_PATH);
affectedModules.add(tailwindFile) before return [...affectedModules].filter(Boolean); After that, change TAILWIND_PATH variable. For example, I have Tailwind file here: How does it work? It forces Vite to reload the main Tailwind file, so all classes are refreshed. You can see additional |
I tried to understand how it works last two hours and I compare it with the Vue 3 implementation. The difference is that in this plugin there are created virtual This is Vue 3 output of This is Vue 2 output of I have a fix for that and I will provide PR in a short time. |
Enormous quantity of <3 to @mihalikv and @antfu for providing a fix, and to @adamwathan for reporting and digging. This was driving me completely crazy 💩 |
Thanks a lot ! |
Reproduction:
https://github.com/adamwathan/vite-vue2-jit-issue
In Tailwind CSS we use the PostCSS dependency message API to tell build tools which files the CSS depends on, so that when those files change the CSS is rebuilt. Tailwind depends on all of your
.vue
files since it generates CSS based on the classes detected in those files, so we register all of those files as dependencies (see thepurge
option in thetailwind.config.js
file).This all works properly with Vite + Vue 3 out of the box, but using Vue 2 with this plugin, the CSS doesn't rebuild when
.vue
files are changed, even though we mark them as dependencies of the CSS.Here's the issue where this was first raised to me if it helps:
tailwindlabs/tailwindcss#6187
...and here's a Vue 3 project where you can see things do work as expected:
https://github.com/adamwathan/vite-issue-repro
Thanks! ❤️
The text was updated successfully, but these errors were encountered: