Vite doesn't inline SVG assets
See original GitHub issuehttps://github.com/vitejs/vite/blob/480367b83a5d418e76a4a6bccd004abb97413c22/src/node/build/buildPluginAsset.ts#L60-L63
Hi. I noticed that svg
files is explicitly excluded in the assetsInlineLimit
feature, and I’m wondering why that is so. Renaming the extension to .SVG
(thus bypassing the .endsWith
check) works fine in my project.
This limit exists since the first time the feature was added, and I’m unable to find any kind of comments or documentation about it. Could someone shed some light on this please? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How to add inline SVGs in a nuxt3 vite project
i found this works <img src="~/assets/images/icons/push-icon-chatops.svg" /> however i need an inline item. so i would do something like this < ...
Read more >Static Asset Handling
Assets smaller in bytes than the assetsInlineLimit option will be inlined as base64 data URLs. Git LFS placeholders are automatically excluded from inlining ......
Read more >Dealing with SVG icons in Vue + Vite
This is just a simple custom Vue component that accepts a prop called name and loads <InlineSvg /> under the hood. As a...
Read more >vite-svg-loader
Vite plugin to load SVG files as Vue components. Latest version: 4.0.0, last published: 21 hours ago. Start using vite-svg-loader in your project...
Read more >How to Import SVGs in a React and Vite app
Are you having difficulties importing SVGs into your React app? ... customizable, and can be animated using CSS when used inline.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We don’t want to use base64 with svg files. See here: https://css-tricks.com/probably-dont-base64-svg/
Basically, base64 is larger in size, and svg files don’t need it to be inlined. In fact, svg files even compress better without base64, because there’s more repetition.
If svg files aren’t inlined currently, they should be. Just without base64.
Look like
!id.endsWith(
.svg)
should be removed… @antfu @aleclarson what do you think?