vite icon indicating copy to clipboard operation
vite copied to clipboard

Tailwindcss doesn't rebuild CSS for new files

Open bluwy opened this issue 1 year ago • 3 comments

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.html and create a new foo.html at the root for example and paste the content in it.
  • Rename text-red-500 in the pasted content to something else new, like text-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

bluwy avatar Nov 01 '24 14:11 bluwy

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

sapphi-red avatar Nov 05 '24 08:11 sapphi-red

Any update on this issue?

brunoalod avatar Apr 15 '25 17:04 brunoalod

Same Problem with Tailwind 4 in Lib Mode

51mydao avatar May 08 '25 09:05 51mydao

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.

bluwy avatar Sep 24 '25 03:09 bluwy