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 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg-symbol-sprite

v1.5.2

Published

A script to generate a symbol sprite from SVG files

Downloads

42,416

Readme

Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

SVG Symbol Sprite

Create an SVG symbol sprite from your SVG files.

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

A Node.js CLI tool which creates an optimized SVG symbol sprite out of a folder full of SVG files.

Provides handy defaults so you don't have to waste time.

All available options can be tweaked. You can even supply your own SVGO config.

This tool is heavily inspried by sprite.sh

Installation

npm i svg-symbol-sprite -g

# or

yarn global add svg-symbol-sprite

Options

| Argument | Description | Default value | | ----------------- | ------------------------------------------------ | ------------------------------------------ | | -i, --input | Specifies input dir | "." (current directory) | | -o, --output | Specifies output file | "./sprite.svg" | | -v, --viewbox | Specifies viewBox attribute | (parsed from each icon) | | -p, --prefix | Specifies prefix for id attribute | "icon-" | | -c, --config | Absolute path to the SVGO config file or "false" | - | | -a, --attrs | Attributes for the SVG element | "aria-hidden="true"" | | -s, --style | Inline style for the SVG element | "width: 0; height: 0; position: absolute;" |

Usage: svg-symbol-sprite [options]

Options:
    -i, --input     Specifies input dir (current dir by default)
    -o, --output    Specifies output file ("./sprite.svg" by default)
    -v, --viewbox   Specifies viewBox attribute (parsed by default)
    -p, --prefix    Specifies prefix for id attribute ("icon-" by default)
    -c, --config    Absolute path to the SVGO config file or "false"
    -a, --attrs     Attributes for the SVG element ('xmlns="http://www.w3.org/2000/svg" aria-hidden="true"' by default)
    -s, --style     Inline style for the SVG element ("width: 0; height: 0; position: absolute;" by default)

Usage as a package.json script

The tool can be also used as a package.json script. You need to add it to the devDependencies of your project's package.json.

{
	"scripts": {
		"svg-sprite": "svg-symbol-sprite -i ./assets/svgs -o ./dist/sprite.svg"
	}
}
npm run svg-sprite

# or

yarn svg-sprite

Usage without installation (with npx)

The tool can be also used without installing it:

npx svg-symbol-sprite -i ./assets/svgs -o ./dist/sprite.svg

SVG Optimization

svg-symbol-sprite optimizes the input SVG files using SVGO and an opinionated configuration file. In order to customize the SVGO config, one can do so by using the -c or --config option and an absolute path to the SVGO config file.

If you wish to completely disable the SVGO files optimization, pass "false" to the --config option.

Accessibility

svg-symbol-sprite does not help with SVG icons' accessibility. This is your responsibility as a developer - you should make sure that your SVGs contain relevant title and id attributes.

LICENSE

MIT