npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-plugin-svg-sprite

v0.6.3

Published

SVG sprite plugin for Vite

Downloads

42,588

Readme

vite-plugin-svg-sprite

A Vite plugin for importing SVG files as SVG sprite symbols or components.

Installation

You can install the plugin using npm, pnpm, or yarn:

npm install vite-plugin-svg-sprite --save-dev
# or
pnpm add vite-plugin-svg-sprite --save-dev
# or
yarn add vite-plugin-svg-sprite --dev

How to Use

To use the plugin, import and configure it in your Vite configuration file (vite.config.js|ts):

import createSvgSpritePlugin from 'vite-plugin-svg-sprite';

const config = {
  plugins: [
    createSvgSpritePlugin({
      exportType: 'vanilla', // or 'react' or 'vue'
      include: '**/icons/*.svg'
    }),
  ],
}

React

For React projects, set the exportType to 'react' to import SVGs as components:

import IconFoo from './icons/foo.svg';

<IconFoo />

This may seem similar to svgr but internally they are different.

vite-plugin-svg-sprite usually has a better render performance.

Vue

For Vue projects, set the exportType to 'vue' to import SVGs as components:

import IconFoo from './icons/foo.svg';

<IconFoo />

Non-React / Non-Vue

For users not using React or Vue, set the exportType to 'vanilla'. The imported value will be the symbolId, which can be used with SVG <use>:

import IconFoo from './icons/foo.svg';
const html = `
  <svg>
    <use href="#${IconFoo}" />
  </svg>
`;

TypeScript Users

To get proper type hints in TypeScript, include the appropriate type definitions in your tsconfig.json:

"types": [
  // or "vite-plugin-svg-sprite/typings/react" | "vite-plugin-svg-sprite/typings/vue"
  "vite-plugin-svg-sprite/typings/vanilla"
],

API Configuration Options

  • symbolId: (string, optional) Controls the generated symbol ID. Default is 'icon-[name]'.

  • exportType: ('vanilla' | 'react' | 'vue', optional) Determines the type of the exported value. Default is 'vanilla'.

    • If set to 'vanilla', the value will be the symbolId.
    • If set to 'react', the value will be a React component.
    • If set to 'vue', the value will be a Vue component.
  • svgo: (object, optional) Configuration for SVGO, refer to the SVGO documentation for details.

  • include: (string | string[], optional) Paths to match SVG files that should be processed. Default is '**/icons/*.svg', following micromatch rules.