Repository navigation
fix: skip lit-css transformation for CSS files requested with ?url - #7
Conversation
Add support for detecting CSS imports with special query parameters (like ?url) that should bypass lit-css transformation and be handled by Vite's default CSS processing instead. Without this change, the build would fail when a CSS file is requested with ?url.
|
hummm interesting... So, you use FWIW: Vite sometimes rewrite some imports when it made an import analysis.... but I dont figure out why this is happening with the |
| @@ -0,0 +1,3 @@ | |||
| import cssUrl from './styles.css?url' | |||
There was a problem hiding this comment.
I have some doubts about if only .css files should be preserved, or we need to support .scss too. Could you please test how this import works in "normal" vite with .scss?
maybe context in: vitejs/vite#15259
There was a problem hiding this comment.
I have some doubts about if only
.cssfiles should be preserved, or we need to support.scsstoo. Could you please test how this import works in "normal" vite with.scss?
In a normal vite without vite-lit-css, with a .scss file (with sass also installed, and after checking that vite runs it by adding some sass variables) I get the URL as expected.
I think vite doesn't make a difference between these... should we?
Now I have a doubt about the ?raw query... if it should also be special-cased in this code.
There was a problem hiding this comment.
Sure! You are right. would you matter add the code for the raw query?
yeah, I've found references to that in I think they replace Although it's not 100% clear to me what happens in this line 655 above when in build. |
| @@ -0,0 +1,3 @@ | |||
| import cssUrl from './styles.css?url' | |||
There was a problem hiding this comment.
Sure! You are right. would you matter add the code for the raw query?
Add support for detecting CSS imports with special query parameters (like ?url) that should bypass lit-css transformation and be handled by Vite's default CSS processing instead.
Without this change, the build would fail when a CSS file is requested with ?url.
A workaround I'm using for now is adding
/[?&]transform-only\b/in my exclude configuration, but that shouldn't be needed. It's not 100% clear to me what is?transform-only, I didn't see any information about it on vitejs documentation so I hope this is somewhat future-proof.Tell me what you think!