Generate CSS after Vite handles imports during prod builds #14850
+183
−6
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.
When we started handling
@import
ourselves in #14446 we inadvertently broke Vite's URL asset url rewriting inside of some imported CSS files.For example, given the following files:
We'd flatten the import CSS and you'd end up with the following:
And, as you can see,
../image.png
does not exist relative to the "final" CSS. It should've been rewritten to./image.png
but was not. Letting Vite handle the imports will rewrite these urls properly — which is what this PR does. It achieves this by running our CSS generation when typtical Vite plugins do rather than before (viaenforce: 'pre'
).Additionally, because we were running the generation step early, Vue had not handled
:deep(…)
selectors in<style scoped>
blocks yet and we were caching the unprocessed CSS. This is also fixed by this PR.Ideally both of these things would be fixable by changing how we handle imports but that will require additional APIs so this is a reasonable stopgap measure until we can do that.
Fixes #14839