2.3.0 • Published 8 months ago

vite-plugin-svelte-svg v2.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Vite Svelte SVG

Vite 3.x plugin to transform SVGs into Svelte components.

It also optimizes your SVGs by running them thru svgo.

npm

<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 vite-plugin-svelte-svg --save-dev
yarn add -D vite-plugin-svelte-svg
pnpm add -D vite-plugin-svelte-svg

Setup

vite.config.js

import svelteSVG from "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:

License

MIT

2.3.0

8 months ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

3 years ago