-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: prevent duplicate CSS files after build #9382
Conversation
vitejs/vite#12207 will be released any day now, so I guess the question is just which solution we'd prefer |
I wasn't sure when the Vite update would be released. Feel free to close this PR if needed. |
With that Vite PR being released now, what's the status here? Set this if we detect Vite<4.2? Anything that needs to be done for user that have 4.2 installed, or do they get this fix automatically? |
I did a quick test with sveltekit.new and it seems that vite 4.2 doesn't automatically fix the issue. Specifying either I think it's still best to go ahead with this fix since it's backwards compatible |
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
🦋 Changeset detectedLatest commit: 3752841 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
LGTM after a changeset
Thank you! |
I just updated to |
I mean there are may duplicates, like:
and so on. The hash is fake in this message. |
Which type of adapter are you using? In some cases, the duplicate CSS files are correct, where URL paths will be different on the server vs the client. The previous CSS duplicates were caused by differences such as values of |
I'm using static adapter. But one of the two files is not used anywhere. If I search it by name in all the build dir I found nothing, the other is there. So one of those two files is generated but not used. |
Got it. That's caused by the builder copying over everything (server + client). This currently can't be disabled at the adapter level, hence this issue. Same thing reported here #9161 |
Prevents duplicate CSS files due to a different hash when the server CSS assets are not minified but the same client CSS is minified.
Explicitly specifying the Vite build option
minify: 'esbuild'
ensures they are always minified.The default is
esbuild
but only minifies JS when it comes to server assets.This is a workaround until Vite has been updated with vitejs/vite#12207 to separately specify CSS minification. This is also nice for those who haven't updated Vite.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.