vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.68k stars 6.21k forks source link

Tailwindcss doesn't rebuild CSS for new files #18552

Open bluwy opened 2 weeks ago

bluwy commented 2 weeks ago

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

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

sapphi-red commented 2 weeks ago

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