Skip to content
PluginStats

vite-plugin-svg-spritemap weekly downloads statistics

By g-makarov · npm · Vite plugins

Generates a SVG spritemap from multiple .svg files

View on npm Fresh · Oct 18, 2026

vite-plugin-svg-spritemap has 8,847 recorded weekly downloads on npm, a decrease of 12.2% over the past 30 days, ranking #989 of 2,322 tracked listings.

Weekly downloads
8,847
Official API · Oct 18, 2026
7-day growth
-56.4%
-11.4K weekly downloads
30-day growth
-12.2%
-1.2K weekly downloads
90-day growth
+400%
+7.1K weekly downloads
Rank
#989
Among tracked npm listings

About vite-plugin-svg-spritemap

vite-plugin-svg-spritemap

CI npm version npm downloads

A Vite plugin that bundles a directory of .svg files into a single spritemap of <symbol> elements.

  • Optionally generates a TypeScript union of the icon names, so a typo is a build error
  • Optimizes icons with SVGO
  • Hoists <defs> to the top level and namespaces their ids, so gradients, patterns and masks keep working and never collide
  • Optional <view> output for <img> and CSS background-image
  • Content hashing for long-term caching
  • HMR: editing an icon swaps it in place, without reloading the page

Requirements

Vite 5–8, Node 20.19+. ESM only.

Installation

npm install -D vite-plugin-svg-spritemap

Usage

// vite.config.ts
import { defineConfig } from 'vite';
import { svgSpritemap } from 'vite-plugin-svg-spritemap';

export default defineConfig({
  plugins: [svgSpritemap({ pattern: 'src/icons/*.svg' })],
});

Each file becomes a <symbol> whose id is the filename without extension — src/icons/arrow.svg → #arrow.

<svg>
  <use href="/spritemap.svg#arrow"></use>
</svg>

The sprite is written to the build output directory and served at the same path in dev. Use the deprecated xlink:href instead of href if you need to support legacy browsers.

React
export const Icon = ({ name }: { name: string }) => (
  <svg>
    <use href={`/spritemap.svg#${name}`} />
  </svg>
);

Turn on types to make name a union of the actual icon names instead of string.

Options

OptionTypeDefaultDescription
patternstring—Glob of the SVG files to include. Required.
filenamestringspritemap.svgOutput filename. Supports [hash].
symbolIdstring | (file, name) => string[name]Template for the symbol ids. Tokens: [name], [dir]. A function gets the file path and the base name.
svgoSVGOConfig | booleantrueSVGO optimization. Pass a config object to customize it.
currentColorbooleanfalseReplace colors with currentColor so icons inherit CSS color.
viewbooleanfalseAlso emit <view> elements, so icons work in <img> and CSS background-image.
hmrbooleantrueUpdate icons in place in dev. Set to false to reload the whole page instead.
typesboolean | stringfalseGenerate a module with the icon names. true writes src/spritemap-icons.ts; pass a path to change it.

The sprite is emitted as a Rollup asset, so other plugins — compression, for instance — see it like any other build output.

Duplicate names

Ids have to be unique within the sprite. With a recursive glob, icons/ui/close.svg and icons/nav/close.svg both want #close; the plugin keeps the first and warns about the second. Set symbolId to tell them apart:

svgSpritemap({ pattern: 'src/icons/**/*.svg', symbolId: '[dir]-[name]' });
// → #ui-close, #nav-close

A literal prefix is just part of the template — symbolId: 'icon-[name]' gives #icon-arrow.

Ids declared inside an icon (gradients, masks, clip paths) are namespaced automatically, so two icons that both define id="a" no longer overwrite each other.

Long-term caching

Put [hash] in filename and the name changes only when the icons do:

svgSpritemap({ pattern: 'src/icons/*.svg', filename: 'sprite-[hash].svg', types: true });

The generated module exports the resolved URL, so nothing has to be hardcoded:

import { iconHref, spritemapUrl } from './spritemap-icons';

spritemapUrl; // '/sprite-a1b2c3d4.svg'
iconHref('arrow'); // '/sprite-a1b2c3d4.svg#arrow'

The dev server keeps a stable [hash] of dev, so references do not go stale on edit.

Icons in <img> and CSS

A <symbol> is never rendered, which is why an <img> pointing at one comes out blank. Turn view on and each icon also gets a <view> framing it, addressable with a -view suffix:

<img src="/spritemap.svg#arrow-view" width="24" height="24" />
.icon {
  background-image: url('/spritemap.svg#arrow-view');
}

Icons used this way cannot inherit currentColor — the browser renders them as an independent document.

Typed icon names

Turn types on and the plugin writes a module listing every symbol in the sprite:

svgSpritemap({ pattern: 'src/icons/*.svg', types: true });
// src/spritemap-icons.ts — generated, do not edit
export const spritemapUrl = '/spritemap.svg';

export const iconNames = ['arrow', 'close'] as const;

export type IconName = (typeof iconNames)[number];…

Description from the npm listing.

  • vite-plugin
  • vite
  • plugin
  • svg
  • spritemap
  • svg-spritemap
  • symbol
  • symbols
  • svg-symbol
  • svg-sprite
  • sprite
  • sprites
  • icon
  • icons
  • typescript

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-plugin-svg-spritemap weekly downloads on npm, last 90 days: 8,847 weekly downloads as of Oct 18, 2026, +400% over 90 days.vite-plugin-svg-spritemapWeekly downloads on npm · Last 90 days8,847downloads / week+400% over 90 days05K10K15K20K25KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
vite-plugin-svg-spritemap weekly downloads on npm, last 90 days: 8,847 weekly downloads as of Oct 18, 2026, +400% over 90 days.

7/30/90-day growth

vite-plugin-svg-spritemap weekly downloads growth on npm: -56.4% over 7 days, -12.2% over 30 days, +400% over 90 days.vite-plugin-svg-spritemapWeekly downloads growth on npm8,847downloads / week now7-day growth-11,427 weekly downloads-56.4%30-day growth-1,233 weekly downloads-12.2%90-day growth+7,079 weekly downloads+400%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
vite-plugin-svg-spritemap weekly downloads growth on npm: -56.4% over 7 days, -12.2% over 30 days, +400% over 90 days.

Ranking history

vite-plugin-svg-spritemap npm ranking history: currently #989 (by weekly downloads).vite-plugin-svg-spritemapnpm ranking · by weekly downloads · Last 90 days#989current rank#300#400#500#600#700#800#900#1000Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 17, 2026 – Oct 20, 2026 · 4 observations · Updated Oct 18, 2026pluginstats.com
vite-plugin-svg-spritemap npm ranking history: currently #989 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,161 shown · page 50, #11 (overall #991)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins253 listings · 13 pages · page 9, #5 (overall #165)
Vite plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (543)
Recent weekly downloads observations for vite-plugin-svg-spritemap
Date (UTC)Weekly downloadsChange vs. previous
8,847-546
9,393-1.3K
10,693-2.2K
12,924-4.7K
17,637-4.2K
21,8740
21,874+1.6K
20,274-179
20,453+479
19,974+1.8K
18,196+795
17,401+2K
15,367-2.1K
17,507—

Similar npm Vite plugins plugins

All 20 vite-plugin-svg-spritemap alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/vite-plugin-svg-spritemap. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.