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

ember-cli-svgstore

v0.4.1

Published

Ember addon to combine SVGs as symbols in a spritesheet.

Downloads

5,791

Readme

ember-cli-svgstore Build Status

This Ember-CLI addon uses broccoli-svgstore to combine the contents of individual SVG files as named symbols in one (or more) master SVGs.

The technique employed is outlined in this CSS Tricks post.

Installation

npm install --save-dev ember-cli-svgstore

Usage

The configuration below would combine all SVGs under e.g. app/icons into one file icons.svg:

// ember-cli-build.js

var app = new EmberApp(defaults, {
  svgstore: {
    files: {
      sourceDirs: 'app/icons',
      outputFile: '/assets/icons.svg'
    }
  }
});

Given an input file in app/icons/user.svg, the contents of that file could be embedded in a page like so:

  <svg role="img">
    <use xlink:href="/assets/icons.svg#user"></use>
  </svg>

SVGs that are processed by this addon are usually more or less static assets, and it makes sense for them to live in the project's public/ dir. However, since ember-cli automatically includes all files in /public in the build, they effectively get duplicated. To prevent processed files from ending up in dist/, use the excludeSourceFiles flag:

// ember-cli-build.js

var app = new EmberApp(defaults, {
  svgstore: {
    excludeSourceFiles: true, // exclude all processed source files
    files: {
      sourceDirs: [ 'public/icons' ],
      outputFile: '/assets/icons.svg',
      excludeSourceFiles: true // exclude source files only for this master SVG
    }
  }
});

Note that if your source SVGs are in any other directory (i.e. /app, /vendor, etc.), they will not automatically be included in the build, and the excludeSourceFiles option is not necessary.

Because this addon uses broccoli-svgstore and svgstore under the hood it's possible to pass the options accepted by svgstore through during the build.

For example, if you wanted to hide your <svg> of <symbols> from view, but still keep it rendered in the DOM, you can take advantage of svgstore's svgAttrs option:

var app = new EmberAddon(defaults, {
  svgstore: {
    excludeSourceFiles: true, // exclude all processed source files
    files: {
      sourceDirs: [ 'public/icons' ],
      outputFile: '/assets/icons.svg',
      excludeSourceFiles: true // exclude source files only for this master SVG
    },
    svgstoreOpts: {
      svgAttrs: {
        style: 'position: absolute; top: 0; left: 0; width: 0%; height: 0%;'
      }
    }
  }
});

See the svgstore options API for more details.

Options

files

May be a single object or an array. Each object should have the following two keys:

  • sourceDirs a string or array of strings specifying the directories that should be crawled for SVGs to include
  • outputFile the destination to write the final SVG to
  • excludeSourceFiles whether the files in sourceDirs are excluded from the build or not

excludeSourceFiles

Boolean indicating whether all source files should be excluded from the build or not, defaults to false.

svgstoreOpts

An options hash to be passed through to svgstore.