poppa / sveltekit-svg

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

Inlining as data url? #26

Closed cornzz closed 1 year ago

cornzz commented 1 year 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 1 year 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'.