Support Vite v5.1.0's .css?url
imports
#8684
Merged
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.
Fixes #7786
This adds built in support for
.css?url
imports in Vite v5.1.0 (currently in beta) to ease migration of Remix's regular CSS imports.The only thing we need to do to support this out of the box is to enable
build.cssMinify
in server builds by default. If we don't do this, content hashes differ between server and client since the server doesn't have minification enabled by default.I've opted to call out the beta status of this feature rather than waiting for Vite 5.1.0 so that it doesn't need to be a blocker for a stable release of the Remix Vite plugin.
We had an existing test for Vite v5.0.x's
.css?url
imports but it didn't use any CSS processing. In order to exercise the new.css?url
support in Vite v5.1.0, I've updated our dev dependency tov5.1.0-beta.6
and modified the test case to use a minimal PostCSS plugin (copied from the Remix compiler's PostCSS tests) so that CSS processing is required for the test to pass. I've confirmed that the updated test fails when using Vite v5.0.x.