-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
imported inline svg files are missing after build #15444
Comments
Start a new pull request in StackBlitz Codeflow. |
Since #14643, if you want to pass the SVG string to a manually constructed url() through a JS framework, in this case StyledComponent, you have to wrap the url with double quotes. Here is the link to that PR and comment regarding it. |
Here is a link to the working example if you want to check it yourself. https://stackblitz.com/edit/vitejs-vite-fkptr2?file=src%2FApp.style.ts There was another issue (#15378) having problem when inlining svg with It seems this is something that can't be handled by vite. Unless there is a fix, I think this specific use case should be documented. My guess is to mention svg inline within Static Asset Handling or Building for Production. Mentioning it within build.assetInlineLimit looks right as well. P.S. If we see this as a problem caused by mismatch of dev and build, maybe we can fix this by breaking dev when using |
Thanks @chaejunlee I'm closing this bug because wrapping the url with double quotes solves the problem. |
Describe the bug
imported tiny ( >
build.assetsInlineLimit
) svg files as url, are not added to cssurl()
function and in fact cause the entire property to be removed from the minified code after buildI import a small svg file as url:
and use it inside a
url
function:the pencil is being displayed on dev but after I build the app, the minified build is missing the entire
background: url(""data:image/svg+xml,{SVG_STRING}") 50% 50% / cover no-repeat;
propertyReproduction
https://stackblitz.com/edit/vitejs-vite-i46sj7?file=src%2Findex.css,src%2FApp.jsx,src%2FApp.style.ts&terminal=dev
Steps to reproduce
npm run dev
npm run build
npm run preview
You can inspect
dist/index{hash}.css
and see that the inline rule is there but when you inspect thediv
, the entirebackground
property is missingSystem Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: