fix(css): stabilize css module hashes with lightningcss in dev mode #19481
+20
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hello!
After upgrading Vite from version 6.0.5 to version 6.0.6 and above, I ran into an issue with hash mismatches in CSS class names in CSS files and in markup.
I found out that the problem is related to this change:
#19001
This PR fixes an issue where CSS module hashes were inconsistent between HTML markup and compiled CSS in development mode when using LightningCSS.
The problem occurred because query parameters (like
?direct
) in file IDs were affecting hash generation in LightningCSS. This was particularly noticeable in frameworks like Qwik that use query parameters for direct imports in dev mode.Fix:
Before the fix:
After the fix:
This fix works for me fine.
If you want to reproduce the problem, you can do the following:
pnpm docs:dev
pnpm add --save-dev vite@6.0.5
and restart dev serverrefs #10514