poppa / sveltekit-svg

SvelteKit plugin that makes it possible to import SVG files as Svelte components, inline SVG code or urls
MIT License
235 stars 23 forks source link

Inlining as data url? #26

Closed cornzz closed 2 years ago

cornzz commented 2 years ago

Hi, I found this plugin hoping that it would allow me to import small svg icons as data url strings which I could directly use as the source of img tags, but was disappointed when I found that it does not allow that (or am I missing something? maybe there is an svgo option for this?) So I guess this is a feature request, would this be possible? Before sveltekit I was using this rollup plugin to achieve the same: https://www.npmjs.com/package/@rollup/plugin-image

poppa commented 2 years ago

Hi @cornzz

I think this is a viable addition so I've already added it. Install the latest version and you will be able to generate inline data URLs by appending ?dataurl to your imports, e.g. import icon from './my-icon.svg?dataurl'.