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
fix: CSS dependencies are tracked incorrectly when base is set #4592
Conversation
The change in vitejs#4267 caused all CSS dependencies of files that are not CSS (Tailwind CSS JIT deps) to be tracked with the `base` prefix in the module graph. URLs in the module graph are normalized and are never prefixed with base and as a result changes to those files were not causing the CSS module to be invalidated. See tailwindlabs/tailwindcss#4978 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a weird solution, but if it works, it works
Yeah, I'm not convinced that using Perhaps it could be wrapped into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the refactoring mentioned by @ElMassimo should be done, but we could get this fix in the meantime.
Is it possible this has broken again somehow? Using vite 2.6.3 and Tailwind (v2 or 3) breaks its JIT mode. Downgrading to Vite 2.4.2 (as suggested in tailwindlabs/tailwindcss#4978 (comment)) resolves the issue. |
@sebastiaanluca would you create an issue with a reproduction to track this? |
Need to do the same for the other ticket, so I'll try and set that up one of these days 👍 |
Description
CSS file dependencies are being tracked incorrectly when the
base
configuration option is set—URLs are being prefixed withbase
in some scenarios.URLs in the module graph are normalized and are never prefixed with
base
, and as a result changes to those files are not causing the CSS module to be invalidated.This pull request ensures the base is removed before passing it to
ensureEntryFromUrl
which is not base-aware.Additional context
The bug was introduced in #4267, released in
2.4.3
.Among other potential bugs, this causes Tailwind CSS in JIT mode to stop working as expected when
base
is specified, because changes to HTML or JS files do not match the module graph file names, and as a result CSS is not invalidated when a change occurs.See tailwindlabs/tailwindcss#4978 (comment) for more context.
What is the purpose of this pull request?