How to stop Vite/SASS from breaking SVG url() references #20267
Replies: 2 comments
-
I was able to come up with one workaround. It no longer produces the error but I don't think it's really a long term solution. I added this to vite.config.js:
|
Beta Was this translation helpful? Give feedback.
-
Upon further investigation, it looks like some weirdness is happening with the way the SVG is being handled before Vite gets hold of it. Ultimately it ends up as a It looks like my problem is not with Vite, but rather trying to work out why the URL-escaping is happening so early in the process. Really it should happen last, just as the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a project that pulls in SASS files, which reference SVG images.
The SVG images have code that uses clip-path, specifically
<svg clip-path="url(#box)">
.However Vite fails to build this project, as the code comes out like this:
The build fails because the inner double-quotes are not escaped, but the underlying problem is that this URL should not be converted to a relative link in the first place. The stacktrace shows the error originates within
node_modules/sass/sass.dart.js
however this is the failure with the double-quotes, so they must be generated before this point.How can I tell Vite to configure the SASS process such that it leave these URLs alone?
Beta Was this translation helpful? Give feedback.
All reactions