# svg-spritemap-webpack-plugin

> Generates symbol-based SVG spritemap from all .svg files in a directory

Latest version **5.1.5** (published 2026-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install svg-spritemap-webpack-plugin
pnpm add svg-spritemap-webpack-plugin
yarn add svg-spritemap-webpack-plugin
bun add svg-spritemap-webpack-plugin
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.5 |
| Published | 2026-10-22 |
| First published | 2016-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.16.0 \|\| >=24.0.0 |
| Dependencies | 9 |
| Unpacked size | 71.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 214 |
| Author | Cas Cornelissen |
| Maintainers | cascornelissen |
| Keywords | svg, sprite, sprites, spritemap, symbols, icons, sass, scss, less, css, variables, webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/svg-spritemap-webpack-plugin
- Repository: https://github.com/cascornelissen/svg-spritemap-webpack-plugin
- Issues: https://github.com/cascornelissen/svg-spritemap-webpack-plugin/issues
- npm.io page: https://npm.io/package/svg-spritemap-webpack-plugin

## Dependencies (9)

- [zod](https://npm.io/package/zod.md) ^4.6.7
- [glob](https://npm.io/package/glob.md) ^13.0.6
- [mkdirp](https://npm.io/package/mkdirp.md) ^3.0.1
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.18.1
- [loader-utils](https://npm.io/package/loader-utils.md) ^3.3.1
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^6.0.1
- [@xmldom/xmldom](https://npm.io/package/@xmldom/xmldom.md) ^0.9.8
- [mini-svg-data-uri](https://npm.io/package/mini-svg-data-uri.md) ^1.4.4
- [svg-element-attributes](https://npm.io/package/svg-element-attributes.md) ^2.2.0

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 5.1.5 (latest) — 2026-10-22
- 5.1.4 — 2026-05-14
- 5.1.3 — 2026-04-28
- 5.1.2 — 2026-04-19
- 5.1.1 — 2026-04-19
- 5.1.0 — 2025-12-06
- 5.0.4 — 2025-11-11
- 5.0.3 — 2025-10-02
- 5.0.2 — 2025-09-27
- 5.0.1 — 2025-09-03
- 5.0.0 — 2025-07-28
- 4.7.0 — 2024-11-18
- 4.6.0 — 2024-09-30
- 4.5.1 — 2024-06-12
- 4.5.0 — 2022-07-13
- … 79 more at https://npm.io/package/svg-spritemap-webpack-plugin/versions

## README

# SVG Spritemap Webpack Plugin
[![npm](https://img.shields.io/npm/v/svg-spritemap-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/svg-spritemap-webpack-plugin)
[![npm](https://img.shields.io/npm/dm/svg-spritemap-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/svg-spritemap-webpack-plugin)
[![license](https://img.shields.io/github/license/cascornelissen/svg-spritemap-webpack-plugin.svg?style=flat-square)](LICENSE.md)

This [webpack][webpack] plugin generates a single SVG spritemap containing multiple `<symbol>` elements from all `.svg`
files in a directory. In addition, it can optimize the output and can also generate a stylesheet containing the sprites
to be used directly from CSS. Chris Coyier has a good write-up about the why's and how's of this technique on
[CSS Tricks][css-tricks-article]. Use it in combination with the [`svg4everybody`][svg4everybody] package to easily and
correctly load SVGs from the spritemap in all browsers.


## Installation
```shell
npm install svg-spritemap-webpack-plugin --save-dev
```


## Usage
**Webpack configuration**  
This plugin can be added to webpack like any other, [documentation on all configuration options](/docs/options.md) is available.

```js
import SVGSpritemapPlugin from 'svg-spritemap-webpack-plugin';

export default {
    // ...
    plugins: [
        new SVGSpritemapPlugin()
    ]
}
```

**SVG element**  
When there's a file `phone.svg` in the source directory and the `prefix` option is set to `sprite-` (default),
the sprite can be included in a HTML-file like so:

```xml
<svg>
    <use xlink:href="/path/to/spritemap.svg#sprite-phone"></use>
</svg>
```


## SVG4Everybody
> [SVG for Everybody][svg4everybody] adds [SVG External Content][svg-external-content-support] support to [all browsers][can-i-use-svg].

It's a good idea to combine the `svg-spritemap-webpack-plugin` with [`svg4everybody`][svg4everybody]. This can be done
by passing an options object or `true` to the `svg4everybody` options key or by initializing SVG4Everybody manually.


## License
This project is [licensed](LICENSE.md) under the [MIT](https://opensource.org/licenses/MIT) license.



[webpack]: https://webpack.github.io/
[css-tricks-article]: https://css-tricks.com/svg-symbol-good-choice-icons/
[svg4everybody]: https://github.com/jonathantneal/svg4everybody
[svg-external-content-support]: http://css-tricks.com/svg-sprites-use-better-icon-fonts/##Browser+Support
[can-i-use-svg]: http://caniuse.com/svg

---
_Source: https://npm.io/package/svg-spritemap-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
