You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This ViteJS plugin generates a single SVG spritemap with <symbol>/<view>/<use> for each SVG files. It can also generate a stylesheet (CSS/SCSS/Stylus/Less) containing the sprites to be used directly (via a Data URI or SVG fragments).
β¨ Use your SVG in an <svg> or <img> tags and also directly in your CSS/SCSS/Stylus/Less
π Import SVG fragment as VueJS component
π₯ HMR support
π¦ Install
npm i -D @spiriit/vite-plugin-svg-spritemap
npm i -D svgo #if you need svgo optimization# yarn
yarn add -D @spiriit/vite-plugin-svg-spritemap
yarn add -D svgo #if you need svgo optimization# pnpm
pnpm add -D @spiriit/vite-plugin-svg-spritemap
pnpm add -D svgo #if you need svgo optimization# bun
bun add -D @spiriit/vite-plugin-svg-spritemap
bun add -D svgo #if you need svgo optimization
π¨βπ» Quick start
Add all your SVGs icons in one folder (like below /src/icons folder for example) and pass the first argument as a glob path including your svg files.
You can access to the spritemap via the route /__spritemap. All files process by ViteJS will transform the path of the file on build. The prefix is sprite- by default.
The plugin will generate a spritemap to support all methods described below (files populated with <view> for fragments and <use> for sprite). This can be configured through options.