-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
vite-plugin-svelte chokes on custom media syntax when using vitePreprocess and Lightning CSS #733
Comments
The issue is caused here:
your style block does not have a "lang" attribute and then vitePreprocess skips it entirely. You can work around it with the current version of vite-plugin-svelte by setting @bluwy any reason not to fall back to 'css' if lang isn't set? |
That works! It's even possible to put custom media queries in a separate file and import it e.g., Thank you! Looking forward to seeing how this is resolved long term. |
I think it was to keep it compatible with Technically Vite always run postcss or lightningcss on all CSS files though, so maybe in the next v-p-s major we can change to always run the preprocessing. |
great point about this being a breaking change and also mentioning lang="postcss". Makes sense to have vitePreprocess process all style nodes with supported langs, but this is going to make it more different from svelte-preprocess. I wonder if we need to document those differences to avoid confusion for users. cc @kaisermann |
I'm not sure what the interaction between
If I set
Would this warrant a new issue in this repo or another? Or would a fix here also fix the This behavior reproduces with the LSP as well: ![]() ![]() |
good question. i assume it still preprocesses the style block with lightningcss if you set lang="postcss" in your code? if yes that would be the workaround for that one. Maybe we should add lang="lightningcss" too ? cc @dummdidumm |
I hadn't even thought to try that, but yes indeed, that does work and lightningcss still processes the style block. |
@bluwy in theory, if |
Describe the bug
I just spun up a new skeleton sveltekit project which by default uses
vitePreprocess
. I installed lightning css (npm i -D lightningcss
) I have modifiedvite.config.ts
to contain the following:Given the following
+page.svelte
file, I can see thenesting
configuration works:With the configuration set as in my first code block, hovering the
<h1>
turns it red. If I comment out thenesting
configuration, hovering the<h1>
does nothing.However, if I uncomment the custom media, I get a syntax error:
Reproduction URL
https://github.com/knpwrs/sveltekit-lightningcss-custom-media-issue
Reproduction
npm create svelte@latest my-app
cd my-app
npm install -D lightningcss
Logs
logs.txt
System Info
The text was updated successfully, but these errors were encountered: