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
broken scss url rewrites with scss variables #5337
Comments
any news on that? I have the same problem with bootswatch: https://stackblitz.com/edit/vitejs-vite-kjplvo?file=package.json |
I didn't get any feedback so I didn't push the PR here. Feel free to pick up the linked change and test if it works for you. |
Can this be separated into different plugin in the meantime? It seems quite drastic to create a new vite version just to fix this issue. (I am also having problem with Bootswatch, but noticed the same issue with our own scss files as well) |
SCSS processing is core vite so I don't believe much can be done in a plugin for that. But the fix is ony a couple of lines divriots@20f34e3 so it shouldn't take too much effort to push it here. |
Seems kinda weird oversight for preferred building block for so many frameworks. That's why I would love to get an input from vite team to confirm that this is an issue and it's taken into consideration. Hard to recommend this for any serious development if you need to "hack it" to work some libraries like |
@gluck if you or others want to send a PR to fix this with some test cases, we should be able to discuss it. Your examples are clear bugs. |
Closing as it is organized into #7651. |
Describe the bug
When an imported scss file has variable
url($foo)
links, they get badly rewritten:scss-import-test/index.scss:
Gets rewritten as (notice the invalid css):
Note that when imported through another (intermediate) scss file, the output is different:
scss-import-test/nested.scss:
Results into (valid css, but the paths aren't rewritten):
I believe this erratic behavior is caused by
rebaseUrls/rewriteCssUrls
being executed on (raw SCSS) content from the first import from src (and only the first, further imports will get processed byvite-url-rewrite
postcss plugin, on CSS ast, with variable interpolated), can probably submit a PR if agreed.Reproduction
https://stackblitz.com/edit/vite-dgawmt?file=index.scss
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: