@hazycora/vite-plugin-svelte-svg
v2.4.3
Published
Vite plugin to load SVG files as Svelte components
Readme
Vite Svelte SVG
Vite plugin to transform SVGs into Svelte components.
It also optimizes your SVGs by running them thru svgo.
<script>
import MyIcon from '$lib/assets/my-icon.svg?component';
// or import MyIcon from '$lib/assets/my-icon.svg?c';
</script>
<MyIcon width={42} height={42} />Install
npm install @hazycora/vite-plugin-svelte-svg --save-devyarn add -D @hazycora/vite-plugin-svelte-svgpnpm add -D @hazycora/vite-plugin-svelte-svgSetup
vite.config.js
import svelteSVG from "@hazycora/vite-plugin-svelte-svg";
export default {
plugins: [
svelteSVG({
svgoConfig: {}, // See https://github.com/svg/svgo#configuration
requireSuffix: true, // Set false to accept '.svg' without the '?component'
}),
],
};Credits
This plugin is based on the work from the following projects:
- https://github.com/codefeathers/rollup-plugin-svelte-svg
- https://github.com/visualfanatic/vite-svg
License
MIT
