Giter Site home page Giter Site logo

broccoli-svgstore's Introduction

broccoli-svgstore

Latest NPM release CircleCI Build Status License Dependencies Dev Dependencies

A Broccoli plugin built on top of broccoli-caching-writer that processes SVGs with svgstore

Installation

npm install --save broccoli-svgstore

Usage

broccoli-svgstore accepts an inputNode -- or a list of inputNodes -- and converts the contents of SVG files found within each node's directory root into SVG <symbol/>s (processing them with svgstore).

The transformed content is then written into a single file (see: the outputFile option), and returned as an output node of the Broccoli build processes.

var svgstore = require("broccoli-svgstore");

var outputNode = svgstore(inputNodes, {
  outputFile: "/assets/icons.svg"
});

For a specific example, check out ember-cli-svgstore's use of broccoli-svgstore

Within your markup, you should now be able to "use" each symbol inside of other SVGs:

<svg><use xlink:href="icon-doge"/></svg>

API

  • inputNode|inputNodes {inputNode or Array of inputNodes}: A standalone Broccoli Node, or a list of them. The root of each node's source directory will form the starting point for a recursive search of .svg files.

  • options {Object}: Options for broccoli-svgstore

Options

  • outputFile {string}: The name of the file -- including any directory path -- to which output will be written (starting from the root directory of your build destination).

    Required: true Default: null

  • annotation {string}: a Broccoli Plugin annotation

    Required: false Default: null

  • svgstoreOpts {Object}: Options to be passed on to svgstore during the processing step.

    Required: false Default: {}

  • prefix {string}: a prefix that will be prepended to each <symbol>'s id

    Required: false Default: undefined

  • fileSettings {Object}: a hash of per-file settings. That is, each root key should correspond to a file name of an SVG that will be found in this node. It's value should then be an Object with any of the following settings:

    • id {string}: A custom id to be used for this SVG's final <symbol>.
    • svgstoreOpts {Object}: same as options.svgstoreOpts, but scoped to the file

    Example usage:

      var outputNode = svgstore(inputNodes, {
        outputFile: "/assets/icons.svg",
        fileSettings: {
          twitter: { id: 'icon-twitter' },
          menu: {
            id: 'icon-hamburger-menu',
            svgstoreOpts: {
              symbolAttrs: { preserveAspectRatio: 'xMinYMid' }
            }
          }
      });

broccoli-svgstore's People

Contributors

briansipple avatar jmarquis avatar haoliangyu avatar greenkeeperio-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.