-
-
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: update inline css url in dev #13007
Conversation
🦋 Changeset detectedLatest commit: 474f0f7 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 |
preview: https://svelte-dev-git-preview-kit-13007-svelte.vercel.app/ this is an automated message |
|
||
if ( | ||
(isCSSRequest(dep.file) || | ||
(query.has('svelte') && query.get('type') === 'style')) && |
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 removed this specific handling (line 205) in the new code since isCSSRequest
should already be capturing any instances of this. I tested in the playground locally and the inlined-styles to prevent fouc still worked.
In the logic where SvelteKit loads the CSS to prevent FOUC in dev, it constructs URLs like
/path/Foo.svelte?svelte=&type=css&lang.css=&inline=
, which isn't great for Vite because it checks if a module is CSS via/\.(css|less|...)(?:$|\?)/
, which wouldn't have matched the constructed URL.With the Vite quirk aside (which fixing it is probably a separate breaking topic in Vite), this PR updates so it looks like this instead:
/path/Foo.svelte?inline&svelte=&type=css&lang.css
, which Vite will be happy about. This is also what Astro does which had also worked well.The reason why it always worked before (and unnoticed) is because
vite-plugin-svelte
was normalizing back to a Vite-happy path: https://github.com/sveltejs/vite-plugin-svelte/blob/da54670065f949c7352597dcafbd51dfa202e638/packages/vite-plugin-svelte/src/index.js#L127-L135. I'm trying to fix some compat for that code for Vite 6 where that will no longer happen, so I figured to fix this here firstPlease 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:
.Edits