Skip to content

susickypavel/vite-plugin-svelte-svg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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';
</script>

<MyIcon width={42} height={42} />

Install

NPM
npm install vite-plugin-svelte-svg --save-dev
Yarn
yarn add -D vite-plugin-svelte-svg
pnpm
pnpm add -D vite-plugin-svelte-svg

Setup

svelte.config.cjs

const svelteSVG = require("vite-plugin-svelte-svg");

module.exports = {
  kit: {
    vite: {
      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

About

⚡️ Vite 2.x plugin to transform SVGs into Svelte components.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%