SVG sprites & stacks

Sprite modes

API

The SVGSpriter module is a low-level building block: register SVG source files, compile, and write the resulting files yourself. See the full API documentation (markdown) for details, or continue below for the command line way.

Command line

Install the CLI globally, then use the svgforge command:

npm install svgforge-cli -g
svgforge --view --view-example --dest=out assets/*.svg

Create a «view» sprite plus an example HTML document.

svgforge --defs --defs-render-css --defs-example --dest=out assets/*.svg

Create a «defs» sprite with a CSS stylesheet and an example document.

svgforge -S -p 10 assets/*.svg

Create a «stack» sprite with 10px padding around all shapes.

svgforge --config config.json 'assets/**/*.svg'

Use a config file and recursive globbing.

Full command line documentation (markdown)