Tailwindcss doesn't rebuild CSS for new files
Describe the bug
I don't remember if we've discussed before, but tailwindcss can't seem to track new files due to limitations of this.addWatchFile: https://github.com/vitejs/vite/blob/fe30349d350ef08bccd56404ccc3e6d6e0a2e156/packages/vite/src/node/plugins/css.ts#L1433-L1444
I'm not sure if we want to special case this, or leave it to tailwind's next major to possibly fix things.
Found this from https://github.com/withastro/astro/issues/12255
Related: https://github.com/vitejs/vite/issues/15460 (but not exactly the same I think)
Reproduction
https://stackblitz.com/edit/vitejs-vite-nk6bcl?file=index.html&terminal=dev
Steps to reproduce
- Start dev server
- Copy the content of
index.htmland create a newfoo.htmlat the root for example and paste the content in it. - Rename
text-red-500in the pasted content to something else new, liketext-green-500 - Open http://localhost:5173/foo and notice that the text is black, not green (for example)
After a full server restart and reload the page, the color is then correctly applied
System Info
n/a
Used Package Manager
npm
Logs
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
We should be able to support this by doing something similar to the vite:import-glob plugin.
https://github.com/vitejs/vite/blob/ad9a987aa4ae3d9e246541d918bb2ec331bbccae/packages/vite/src/node/plugins/importMetaGlob.ts#L91-L105
Any update on this issue?
Same Problem with Tailwind 4 in Lib Mode
I'm going to close this for now as tailwind has introduce its own vite plugin, which should mean that any issues should/can be fixed there instead. Maybe we can revisit this again if there's another tooling that relies on this behaviour.