
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
ember-cli-svgstore
Advanced tools
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.
npm install --save-dev ember-cli-svgstore
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.
filesMay 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 includeoutputFile the destination to write the final SVG toexcludeSourceFiles whether the files in sourceDirs are excluded from the build or notexcludeSourceFilesBoolean indicating whether all source files should be excluded from the build or not, defaults to false.
svgstoreOptsAn options hash to be passed through to svgstore.
FAQs
Ember addon to combine SVGs as symbols in a spritesheet.
The npm package ember-cli-svgstore receives a total of 178 weekly downloads. As such, ember-cli-svgstore popularity was classified as not popular.
We found that ember-cli-svgstore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.