GithubHelp home page GithubHelp logo

grunt-svgstore's Introduction

grunt-svgstore NPM version Build Status

Merge SVGs from a folder.

Want to help?

I am looking for a maintainer who would like to take over this plugin.

Why?

Because Chris Coyier asked.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-svgstore --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-svgstore');

Screencast

Chris made a screencast, using grunt-svgstore in a real project, you can find it here.

The "svgstore" task

Overview

In your project's Gruntfile, add a section named svgstore to the data object passed into grunt.initConfig().

grunt.initConfig({
  svgstore: {
    options: {
      prefix : 'icon-', // This will prefix each ID
      svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
        viewBox : '0 0 100 100',
        xmlns: 'http://www.w3.org/2000/svg'
      }
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.prefix

Type: String
Default value: ''

A string value that is used to prefix each filename to generate the id.

options.svg

Type: Object
Default value: {}

An object that is used to generate attributes for the resulting svg file.

{
  viewBox: '0 0 100 100'
}

will result in:

<svg viewBox="0 0 100 100">
[...]

options.symbol (since 0.2.4)

Type: Object
Default value: {}

Just like options.svg but will add attributes to each generated <symbol>.

options.formatting (since 0.0.4)

Type: Object or boolean
Default value: false

Formatting options for generated code.

To format the generated HTML, set formatting with options like: {indent_size : 2}, which in context looks like:

default: {
  options: {
    formatting : {
      indent_size : 2
    }
  }

See js-beautify for more options.

options.includedemo (since 0.3.5)

Type: boolean|string|function
Default value: false

This will include a demo HTML (named like destName + -demo.html) from where you can copy your <use> blocks.

The default template used looks like:

<!doctype html>
<html>
  <head>
    <style>
      svg{
       width:50px;
       height:50px;
       fill:black !important;
      }
    </style>
  <head>
  <body>
    {{{svg}}}

    {{#each icons}}
        <svg>
          <use xlink:href="#{{name}}" />
        </svg>
    {{/each}}

  </body>
</html>

Since 0.3.5 you can customise this by passing in a string that will be compiled via handlebars and used as a tempalte. If it is a function this function is expected to take one parameter and return a string.

The data passed to the template looks like this:

{
  svg : '[raw HTML of the generated svg]',
  icons : [
    name : 'name of an item',
    title : 'extracted title or name'
  ]
}

options.cleanup (since 0.2.6)

Type: boolean or Array Default value: false

This option can be used to clean up inline definitions that may jeopardise later CSS-based styles.
When set to true clean up all inline style attributes.
Apart from true / false, the value of this property can be an array of inline attributes ( like fill, stroke, ...) you want to remove from the elements in the SVG.

options.cleanupdefs (since 0.3.0)

Type: boolean
Default value: false

When set to false, no cleanup is performed on the <defs> element.

options.inheritviewbox (since 0.4.0)

Type: boolean
Default value: false

By default, each generated <symbol> will only automatically have a viewBox attribute set if the original source SVG file for that symbol has a viewBox.

When inheritviewbox is set to true, if the source SVG has no viewBox but it does have a pixel-based width and height, then the <symbol> viewBox will be derived using those values instead.

For example, with inheritviewbox: true,

<svg width="256" height="128">

will result in:

<symbol viewBox="0 0 256 128" ...>

options.convertNameToId (since 0.4.0)

Type: function

The function used to generate the ID from the file name. The function receives the file name without the .svg extension as its only argument.

The default implementation:

function(name) {
  var dotPos = name.indexOf('.');
  if ( dotPos > -1){
    name = name.substring(0, dotPos);
  }
  return name;
}

options.fixedSizeVersion (Since 0.4.0)

Type: Object or boolean Default value: false

When true or a configuration object is passed for each of the symbols another one, with suffixed id generated. All those additional symbols have the common dimensions and refers to the original symbols with <use>. Original symbols are placed exactly in the middle of the fixed-size viewBox of the fixed size version.

Configuration reference and default values if true is passed:

grunt.initConfig({
  svgstore: {
    options: {
      fixedSizeVersion: {
        width: 50,
        height: 50,
        suffix: '-fixed-size',
        maxDigits: {
          translation: 4,
          scale: 4,
        },
      },
    },
  },
});

Any of the configuration object properties may be omitted.

Usage Examples

This example will merge all elements from the svgs folder into the <defs>-Block of the dest.svg. You can use that SVG in HTML like:

<!-- Include dest.svg -->

[...]

<svg><use xlink:href="#filename" /></svg>
grunt.initConfig({
  svgstore: {
    options: {},
    default : {
      files: {
        'dest/dest.svg': ['svgs/*.svg'],
      },
    },
  },
});

options.includeTitleElement (since 0.5.0)

Type: Boolean Default value: true

Include a <title> element for screen readers. Uses the filename if no <title> was found on the source SVG. Set to false only if you are providing your own accessible name in your code.

options.preserveDescElement (since 0.5.0)

Type: Boolean Default value: true

Preserve <desc> element for screen readers if present. Set to false to suppress.

options.removeWithId

Type: String Default value: null

Use this option to provide an ID of an SVG element you'd like removed. Likely use case is a bounding box path. Simply add id='remove-me' and then supply removeWithId: 'remove-me' in the options.

Supplemental Features

There are some hidden features available in grunt-svgstore:

  • Use the preserve-- prefix (in the source SVG), for any attributes that should be forced to remain in the resulting SVG. For example, preserve--stroke would result in just stroke in the resulting SVG. This happens whether or not you ask for that attribute to be cleaned via cleanup.
  • Using the value of currentColor on any property with the key fill, will result in that property remaining in the resulting SVG (regardless of whether or not you ask for fill to be cleaned via cleanup). This can be used to achieve accent color for you SVG instances by defining the font color on a parent element via the CSS color property.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

grunt-svgstore's People

Contributors

0b10011 avatar ain avatar carlrosell avatar corpulentcoffee avatar cverdoes avatar danburzo avatar endorama avatar frank3k avatar fweinb avatar ginader avatar hamsterbacke23 avatar huntedpix avatar ianmcnally avatar jnowland avatar jonathantneal avatar jrencz avatar pdehaan avatar quasipickle avatar roblevintennis avatar rowno avatar ry5n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-svgstore's Issues

Auto generate image dimensions

Hi!
Is it possible to add option for auto generating css file with image dimensions?
Like

.svg-name-1 {
    width: 15px;
    height: 15px;
}

.svg-name-2 {
    width: 20px;
    height: 20px;
}

It would be nice.

Titles include meta file extenstions (like .min)

I know the issue with IDs was fixed a few days ago, and I really appreciate that (means I can use it in production); however, the same issue still seems to apply to the <title> tags. Much smaller issue, but still important to note.

"XML Parsing Error" in FireFox

I created pretty huge SVG icon set for one of my project. The issue is that some of the icons use xlink:href itself. I mean there is a simple file a.svg like this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 64 64">
    <rect x="4" y="4" width="56" height="56" />
</svg>

and I use it in another file b.svg like this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 64 64">
    <use xlink:href="#icon-a" />
</svg>

The problem is that FireFox throws "XML Parsing Error: prefix not bound to a namespace" because of lack of xmlns:xlink attribute. As I can see there is only an option to define xlink parameter but not any of other namespaces like mentioned xmlns:xlink, `xmlns:xsl' or any others.

I did some work around with other grunt task grunt-string-replace to add missing namespace but that would be nice to be able to declare that inside the task.

Undefined this[0].attribs

In this part, this[0] is always undefined for me. I don't quite understand what causes this issue.

$('*').each(function(){
for ( var attr in this[0].attribs){

Toggle between G and Symbol

Nice module. I can understand the use of symbol however using 'symbol' in place of 'g' prevents svgs using fragment identifiers from showing as background images.

eg: background-image: url('../images/search.svg#shape-search');

Perhaps make it an option in grunt for us to toggle whether we prefer G or symbol?

Regards Steven

Handeling the <defs> block in SVGs

Currently the block is ignored. So merging svgs that are build with custom filters or <use> will break!

Ids aren't a problem because all ids are prefixed by the md5 hash of the file they are from, so there aren't any collisions.

option to control extra elements like title and description

Hey,
I'm using the beautiful svgstore with together with svgmin and was wondering why svgmin didn't remove the <title> and <desc>. After digging in the source I saw that the fields are readded from svgstore… Therefore an additional option to control extra elements would be great!

Cheers

SVG-map pushes down HTML-content / CSS fill not working on every second SVG

When using grunt-svgstore to combine my SVGs, the created SVG-map pushes down the complete HTML-content when embedding it with PHP:

...
<body>
    <?php include_once("public/sprite/svg-defs.svg"); ?>
...

Any idea how to solve that?

Furthermore, the fill-attribute via CSS to style the SVGs works only on every second SVG. The others stay black.

This is my Gruntfile:

svgstore: {
      options: {
        prefix : 'shape-', // This will prefix each ID
        svg: { // will add and overide the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
          viewBox : '0 0 100 100',
          xmlns: 'http://www.w3.org/2000/svg'
        }
      },
      your_target: {
        files: {
        'public/sprite/svg-defs.svg': ['svg/*.svg'],
        }
      },
    },

And I assign the following CSS:

.icon {
  display: inline-block;
  width: 50px;
  height: 50px;
}

.shape-STAR {
  fill: #ff0000;
}

.shape-SUN {
  fill: green;
}

.shape-WIFI {
  fill: red;
}

.shape-SPEAKER {
  fill: green;
}

.shape-STOP{
  fill: yellow;
}

.shape-UMBRELLA{
  fill: yellow;
}

This is how I embed them:

<svg viewBox="0 0 100 100" class="icon shape-STAR">
          <use xlink:href="#shape-STAR"></use>
        </svg>

        <svg viewBox="0 0 100 100" class="icon shape-WIFI">
          <use xlink:href="#shape-WIFI"></use>
        </svg>

        <svg viewBox="0 0 100 100" class="icon shape-SUN">
          <use xlink:href="#shape-SUN"></use>
        </svg>

        <svg viewBox="0 0 100 100" class="icon shape-SPEAKER">
          <use xlink:href="#shape-SPEAKER"></use>
        </svg>

        <svg viewBox="0 0 100 100" class="icon shape-STOP">
          <use xlink:href="#shape-STOP"></use>
        </svg>

        <svg viewBox="0 0 100 100" class="icon shape-UMBRELLA">
          <use xlink:href="#shape-UMBRELLA"></use>
        </svg>

I am running on localhost, Apache 2.4.7 with Chrome 37.0.2062.120 (64-bit).

Any idea what's wrong?

Gulp version?

I know this isn't issue, but is there some possibility for a Gulp version in future?

NPM standard formatting

I'd like to propose revising the formatting of the module to match better with the majority of the modules out there, e.g. 2 spaces for tabs, etc.

Problem with dependencies

I'm not able to install the current version of svgstore through npm (but have no problem installing other packages):

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-svgstore" "--save-dev"
npm ERR! cwd boilerplate
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! boilerplate\npm-debug.log
npm ERR! not ok code 0

I've tried installing version 0.0.3, and that works fine. Maybe a problem with the dependencies.

Running grunt task produces error

Running the svgstore task produces an error and fails to run. I have seen others in the CSS Tricks comments report the same.

Loading "svgstore.js" tasks...ERROR
>> Error: Cannot find module 'cheerio'

ID Stripping

Because svgstore appends ID's, is that why it also strips ID's from other elements? So there isn't a conflict? That would make sense.

The issue for me is that when you name layers in Adobe Illustrator, it puts those as ID's on the elements. That's a kind of nice workflow. I updated my copy to append a class name of the ID as it's stripping it, so I still have something I can select by.

Not sure if that's something that is smart for everyone though.

It also might be a good note that the cleanup option, even when false, doesn't prevent the ID stripping.

SVGStore bakes extensions into IDs of symbols

If you name a source SVG "logo-image.min.svg", SVG store makes it's ID "[prefix]-logo-image.min", which isn't a valid ID and also not the desired result.

Additionally, if there are spaces in the file name, the spaces are included in the ID attribute.

Should this support SVG animations?

I don't know if this should work or not and I did not investigate enough yet, but if I'm taking this working SVG animation example and process it with grunt-svgstore, the animation does not work anymore:

<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
    <path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634 c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/>
    <path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z">
        <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20" dur="1s" repeatCount="indefinite"/>
    </path>
</svg>

grunt-svgstore changes the file content to the following:

<svg xmlns="http://www.w3.org/2000/svg">
    <symbol viewBox="0 0 40 40" id="icon-loading">
        <title>loading</title>
        <path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634 c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/> <path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z"/>
        <animatetransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20" dur="1s" repeatCount="indefinite"/>
    </symbol>
</svg>

The first thing I see is that the "animation" element should be a child element of the path.
grunt-svgstore closes the preceding "path" element (so it's self-closing), and it puts the "animation" element after the "path".

But even if I change that manually, there seems to be a problem because of the additional "symbol" tag.

So basically, the question is - should this work with SVG animation and do I just need to change the SVG code in the first place?

Option for SVG inline style cleanup

SVG editing software tends to generate inline styles that define the fill for the path. That is rather hard to work with as with anything that has inline styles. Therefore I'd suggest implementing a cleanup option that would enable to preprocess SVGs and remove any inline styles to have a clean start for styling.

Example SVG from Inkscape (input):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="64"
   height="64"
   id="svg3315">
  <defs
     id="defs3317" />
  <metadata
     id="metadata3320">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     id="layer3"
     style="display:inline">
    <path
       d="M 32.023548,13.911903 64.114266,44.069169 61.158286,47.02306 32.023548,19.819685 2.9238456,47.538113 -0.03004543,44.584221 z"
       id="path3317"
       style="fill:#2b2b2a;fill-opacity:1;fill-rule:nonzero;stroke:none" />
  </g>
</svg>

Proposed preprocessed SVG by svgstore (output):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="64"
   height="64"
   id="svg3315">
  <defs
     id="defs3317" />
  <metadata
     id="metadata3320">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     id="layer3"
     style="display:inline">
    <path
       d="M 32.023548,13.911903 64.114266,44.069169 61.158286,47.02306 32.023548,19.819685 2.9238456,47.538113 -0.03004543,44.584221 z"
       id="path3317" />
  </g>
</svg>

Dependencies

Trying to compile this gives me a couple of errors regarding dependencies. Namely, 'chalk' and 'cheerio' not being available. Installing both of these (i.e. npm install chalk, npm install cheerio) stops the errors ( 'Done, without errors') – however when I run the task nothing happens in my filesystem. Any suggestions?

All other grunt tasks running fine.
Grunt version: ~0.4.2

Create a getting started / best practice guide

The workflow improvements discussed in #16 have an impact on the usage of grunt-svgstore so I would like to update/create a getting started and best practice guide.

If implementing the proposed idea from #1 the user will have to use css like:

.svg-sprite{
  width:0;
  height:0;
  visibility:hidden;
}

instead of the current display:none; to hide the svg sprite to keep linearGradient working.

v0.0.2 install error

Thanks for fixing the dependency error in v0.0.1, but when I attempt to install v0.0.2 I now get this error:

npm ERR! Error: No compatible version found: cheerio@'^0.13.1'

The full output is here, in case it helps:

npm WARN package.json [email protected] No README.md file found!
npm http GET https://registry.npmjs.org/grunt-svgstore
npm http 304 https://registry.npmjs.org/grunt-svgstore
npm http GET https://registry.npmjs.org/cheerio
npm http GET https://registry.npmjs.org/chalk
npm http 304 https://registry.npmjs.org/cheerio
npm http 304 https://registry.npmjs.org/chalk
npm ERR! Error: No compatible version found: cheerio@'^0.13.1'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.2.0","0.2.1","0.2.2","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.4.2","0.5.0","0.5.1","0.5.2","0.6.0","0.6.1","0.6.2","0.7.0","0.8.0","0.8.1","0.8.2","0.8.3","0.9.0","0.9.1","0.9.2","0.10.0","0.10.1","0.10.2","0.10.3","0.10.4","0.10.5","0.10.6","0.10.7","0.10.8","0.11.0","0.12.0","0.12.1","0.12.2","0.12.3","0.12.4","0.13.0","0.13.1"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:685:10)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:607:10
npm ERR!     at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-svgstore" "--save-dev"
npm ERR! cwd /Users/myuser/Dropbox/htdocs/myproject
npm ERR! node -v v0.10.5
npm ERR! npm -v 1.2.18
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/myuser/Dropbox/htdocs/myproject/npm-debug.log
npm ERR! not ok code 0

SVGs using filters do not appear in Firefox

I have come across an issue where SVG files that have filters do not appear in firefox (tested on version 31). This appears to be because the filters are not defined in the defs block. I was able to quite easily fix this with the following code:

//Put any filters into the defs block
$resultDocument('filter').each(function(){
var $elem = $resultDocument(this);
$resultDefs.append( $elem );
//console.log( 'filter', $elem );
});

Added just before the line "// Remove defs block if empty". I have not tested extensively, but this seems to work, and I cannot see any reason why this would cause any issues.

White space is preserved

Newlines, linebreaks, tabs are parsed by cheerio despite the ignoreWhitespace: true setting.

I had to remove unwanted whitespace with a regexp. I wonder if ignoreWhitespace is valid for HTML documents only and not XML (?).

Cross-icon gradient use

I'm having an issue with sharing gradients across icons. This circle will work:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
    <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
    <stop offset="0%" stop-color="#009fe3" />
    <stop offset="100%" stop-color="#662483" />
    </linearGradient>
    <circle cx="50" cy="50" r="75" fill="url(#grad1)"/>
</svg>

But then I can't reference that same gradient later, eg:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
      <rect width="75" height="75" fill="url(#grad1)" />
</svg>

It seems to be because of the way SVG store handles the ids. It prepends the file hash on to the beginning of the ids to make it unique (which it rightly should) but this change doesn't seem to permeate through the rest of the file. so you end up with a sprite like this:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" class="hide">
    <defs>
        <linearGradient id="[hash]grad1" x1="0%" y1="0%" x2="100%" y2="0%">
            <stop offset="0%" stop-color="#009fe3"/>
            <stop offset="100%" stop-color="#662483"/>
        </linearGradient>
    </defs>
    <symbol viewBox="0 0 100 100" id="icon__circle">
        <title>circle</title>
        <circle cx="50" cy="50" r="75" fill="url(#[hash]grad1)" />
    </symbol>
    <symbol viewBox="0 0 100 100" id="icon__rectangle">
        <title>rectangle</title>
        <rect width="75" height="75" fill="url(#grad1)" />
    </symbol>
</svg>

Everything would work fine if the reference to the gradient in the second (rectangle) icon was updated to use the hashed id. Alternatively, if there was a way to preserve the ID that would be even better. It would allow you to write the following CSS:

.icon__grad-1{
    fill: url(#grad1);
}

Obviously I would use a more specific ID in production code, but you get the idea.

svgz

is it possible, to output svgz, too?

Support Sketch NS

This doesn't work when your items are exported from Sketch. The issue appears the Namespace that sketch uses.

 Here is an example SVG exported from sketch:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="512px" height="512px" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <title>chart-bar-graph</title>
    <description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
    <defs></defs>
    <g id="Icons" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
        <g id="chart-bar-graph" sketch:type="MSArtboardGroup" fill="#000000">
            <path d="M384,320 L512,320 L512,512 L384,512 L384,320 L384,320 Z M192,0 L320,0 L320,512 L192,512 L192,0 L192,0 Z M128,160 L128,512 L0,512 L0,160 L128,160 L128,160 Z" id="Shape" sketch:type="MSShapeGroup"></path>
        </g>
    </g>
</svg>

IDs within "url()" aren't made unique

Hey thanks for this awesome task. It's a real time saver!

So there's just a small issue where IDs within url references don't get handled, which breaks references within the final SVG output.

Here's an example:

    <path fill="url(#b)" d="M20.426 26.117l3.631-1.997c.736-.407.736-1.068 0-1.473l-3.645-2.004-2.73 2.73 2.744 2.744z"/>
    <linearGradient id="b" gradientUnits="userSpaceOnUse" x1="485.463" y1="-496.876" x2="500.38" y2="-492.976" gradientTransform="matrix(.707 .707 -.707 .707 -679.147 21.663)">

When the above is run through grunt-svgstore, the linearGradient ids are all made unique, but url references within fill remain the same. So the gradient wouldn't work in the final SVG.

Here's a really crude fix that I added to my local version of svgstore.js

    // Make fill attributes with ID references unique
    $('[fill]').each(function() {
      var $elem = $(this);
      var fill = $elem.attr('fill');

      // pull out if no url reference specified
      if ( fill.indexOf('url(') < 0 ) return;

      var fillRegex    = fill.match( /\((.*)\)/ );
      var urlReference = fillRegex[1];

      // pull out if not an ID reference
      if  ( urlReference.charAt(0) !== '#' ) return;

      // get the id by name
      var id = urlReference.slice(1, urlReference.length);

      // set the new unique id reference
      $elem.attr('fill', 'url(#'+ uniqueId + id +')');
    });

The above isn't perfect, but it works. It only trawls through elements with fill attributes, but there could be other attributes that contain url(#id) style references. I'm not too sure what they are though.

Hopefully you can add in something like that so that the final SVG output makes ALL IDs unique, rather than just a few.

Cheers

Additional "preserve fill" and "preserve stroke" options

@FWeinb I'm pondering another idea on how we can achieve multiple colors for fills and strokes (even when cleanup is requested. As of the currentColor addition, you can now achieve two colors (one defined in any of the ancester containing block's color property, and the other with whatever fill is defined on the xlink itself). However, I think we could go further if we allow hard coded inline values to be preserved as requested.

To make this clearer, say I have the following:

**omitted for brevity**
<path fill="#ff0000" d="M0,0v32h32V0H0z M30,30H2V2h28V30z M8,8h16v16H8V8z"/>
<rect fill="currentColor" x="3.8" y="4" width="3.8" height="3.8"/>
<rect fill="green" x="24.8" y="24" width="3.8" height="3.8"/>
</svg>

currentColor will now be preserved but the other two fill will be stripped. If my intent is to preserve the fill="green", I'm wondering if we might add a preserve-fill which gets resolved like:

<rect preserve-fill="green"...

becomes

<rect fill="green"

A corresponding preserve-stroke could also be added. I think this would be fairly trivial to add, but could allow the potential for 3+ colors on an xlink svg. @FWeinb Thoughts?

P.S. I'll code it if you agree with it philosophically :- )

Improving Workflow

So, I finally got the SVG sprite to work, but since the width and height attributes are not set dynamically one has to enter them in manually otherwise the icons sit at the bottom of the viewport. Output is below, but here's a pen to view also… http://codepen.io/grayghostvisuals/pen/f8a269745f17d11e8ae77bec37630170

<svg viewBox="0 0 32 32">
  <defs>
    <g id="icon-cloud">
      <path d="M32 20.548c0-2.565-1.771-4.716-4.156-5.296-0.101-4.022-3.389-7.252-7.433-7.252-2.369 0-4.477 1.109-5.839 2.835-0.764-0.987-1.959-1.624-3.303-1.624-2.307 0-4.176 1.871-4.176 4.179 0 0.201 0.015 0.399 0.043 0.592-0.351-0.063-0.711-0.098-1.080-0.098-3.344-0-6.054 2.712-6.054 6.058 0 3.346 2.71 6.058 6.054 6.058l20.508-0c3.004-0.006 5.438-2.444 5.438-5.451z" fill="#000000"></path>
    </g>
    <g id="icon-info"><g></g>
      <path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM16 29c-7.18 0-13-5.82-13-13s5.82-13 13-13 13 5.82 13 13-5.82 13-13 13zM14 8h4v4h-4zM20 24h-8v-2h2v-6h-2v-2h6v8h2z" fill="#000000"></path>
    </g>
    <g id="icon-menu"><g></g>
      <path d="M2 6h28v6h-28zM2 14h28v6h-28zM2 22h28v6h-28z" fill="#000000"></path>
    </g>
  </defs>
</svg>

<!--
Authors need to add these blocks below manually. 
Would be nice to add them in the SVG output file.
-->
<svg viewBox="0 0 32 32" class="svg-icon">
  <use xlink:href="#icon-cloud"></use>
</svg>

<svg viewBox="0 0 32 32" class="svg-icon">
  <use xlink:href="#icon-menu"></use>
</svg>

Namespace prefix inkscape for pageopacity on namedview is not defined

SVGs created by Inkscape have a following problem once concatenated (from Safari):

error on line 1 at column 351: Namespace prefix inkscape for pageopacity on namedview is not defined

1st SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="64"
   height="64"
   id="svg3315"
   version="1.1"
   inkscape:version="0.48.2 r9819"
   sodipodi:docname="icon-logout.svg">
  <defs
     id="defs3317" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="2.8"
     inkscape:cx="37.921858"
     inkscape:cy="38.336"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="767"
     inkscape:window-height="517"
     inkscape:window-x="276"
     inkscape:window-y="77"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata3320">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-988.36218)">
    <path
       inkscape:connector-curvature="0"
       d="m 53.808483,1050.3713 -43.429508,0 0,-32.8261 43.429508,0 0,32.8261 z m -6.260221,-35.1727 -0.978409,0 -26.604522,0 0,-0.1591 0,-10.1364 0,-1.9931 c 0,-6.68862 5.440904,-12.12838 12.128398,-12.12838 6.686358,0 12.128399,5.44204 12.128399,12.12838 l 0,1.9931 2.347725,0 0,-1.9931 c 0,-7.98293 -6.493176,-14.47611 -14.476124,-14.47611 -7.982947,0 -14.476124,6.49431 -14.476124,14.47731 l 0,12.2886 -9.586355,0 0,37.5192 48.124959,0 0,-37.5204 -8.607947,0 z"
       style="fill:#1d1d1d;fill-opacity:1;fill-rule:nonzero;stroke:none"
       id="path28" />
  </g>
</svg>

2nd SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="64"
   height="64"
   id="svg3315"
   version="1.1"
   inkscape:version="0.48.2 r9819"
   sodipodi:docname="Uus dokument 2">
  <defs
     id="defs3317" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="2.8"
     inkscape:cx="37.921858"
     inkscape:cy="38.336"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="767"
     inkscape:window-height="517"
     inkscape:window-x="276"
     inkscape:window-y="77"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata3320">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-988.36218)">
    <g
       id="g3369"
       transform="matrix(0.74062091,0,0,0.74062091,14.528,262.00513)">
      <g
         transform="matrix(1.25,0,0,-1.25,17.483881,988.80851)"
         id="g62">
        <path
           id="path64"
           style="fill:#2f2d2d;fill-opacity:1;fill-rule:nonzero;stroke:none"
           d="m 0,0 0,-2.358 37.499,0 0,-51.83 -37.499,0 0,-2.355 39.854,0 L 39.854,0 0,0 z"
           inkscape:connector-curvature="0" />
      </g>
      <g
         transform="matrix(1.25,0,0,-1.25,28.513261,1046.5049)"
         id="g66">
        <path
           id="path68"
           style="fill:#2f2d2d;fill-opacity:1;fill-rule:nonzero;stroke:none"
           d="M 0,0 1.829,-1.829 21.543,17.884 1.829,37.597 0,35.771 16.596,19.177 l -54.962,0 0,-2.584 54.958,0 L 0,0 z"
           inkscape:connector-curvature="0" />
      </g>
    </g>
  </g>
</svg>

Result by grunt-svgstore:

<svg xmlns="http://www.w3.org/2000/svg"><symbol id="icon-access"><title>icon-access</title>  <sodipodi:namedview id="56cf8a18af9ca0581ded35b784df5896base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.8" inkscape:cx="37.921858" inkscape:cy="38.336" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="767" inkscape:window-height="517" inkscape:window-x="276" inkscape:window-y="77" inkscape:window-maximized="0"/> <metadata id="56cf8a18af9ca0581ded35b784df5896metadata3320"> <rdf:rdf> <cc:work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:title/> </cc:work> </rdf:rdf> </metadata> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="56cf8a18af9ca0581ded35b784df5896layer1" transform="translate(0,-988.36218)"> <path inkscape:connector-curvature="0" d="m 53.808483,1050.3713 -43.429508,0 0,-32.8261 43.429508,0 0,32.8261 z m -6.260221,-35.1727 -0.978409,0 -26.604522,0 0,-0.1591 0,-10.1364 0,-1.9931 c 0,-6.68862 5.440904,-12.12838 12.128398,-12.12838 6.686358,0 12.128399,5.44204 12.128399,12.12838 l 0,1.9931 2.347725,0 0,-1.9931 c 0,-7.98293 -6.493176,-14.47611 -14.476124,-14.47611 -7.982947,0 -14.476124,6.49431 -14.476124,14.47731 l 0,12.2886 -9.586355,0 0,37.5192 48.124959,0 0,-37.5204 -8.607947,0 z" style="fill:#1d1d1d;fill-opacity:1;fill-rule:nonzero;stroke:none" id="56cf8a18af9ca0581ded35b784df5896path28"/> </g> </symbol><symbol id="icon-exit"><title>icon-exit</title>  <sodipodi:namedview id="ebe72facf38321d9649f2e005f1957b2base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.8" inkscape:cx="37.921858" inkscape:cy="38.336" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="767" inkscape:window-height="517" inkscape:window-x="276" inkscape:window-y="77" inkscape:window-maximized="0"/> <metadata id="ebe72facf38321d9649f2e005f1957b2metadata3320"> <rdf:rdf> <cc:work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:title/> </cc:work> </rdf:rdf> </metadata> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="ebe72facf38321d9649f2e005f1957b2layer1" transform="translate(0,-988.36218)"> <g id="ebe72facf38321d9649f2e005f1957b2g3369" transform="matrix(0.74062091,0,0,0.74062091,14.528,262.00513)"> <g transform="matrix(1.25,0,0,-1.25,17.483881,988.80851)" id="ebe72facf38321d9649f2e005f1957b2g62"> <path id="ebe72facf38321d9649f2e005f1957b2path64" style="fill:#2f2d2d;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0,0 0,-2.358 37.499,0 0,-51.83 -37.499,0 0,-2.355 39.854,0 L 39.854,0 0,0 z" inkscape:connector-curvature="0"/> </g> <g transform="matrix(1.25,0,0,-1.25,28.513261,1046.5049)" id="ebe72facf38321d9649f2e005f1957b2g66"> <path id="ebe72facf38321d9649f2e005f1957b2path68" style="fill:#2f2d2d;fill-opacity:1;fill-rule:nonzero;stroke:none" d="M 0,0 1.829,-1.829 21.543,17.884 1.829,37.597 0,35.771 16.596,19.177 l -54.962,0 0,-2.584 54.958,0 L 0,0 z" inkscape:connector-curvature="0"/> </g> </g> </g> </symbol></svg>

Non-existant target folder fails the task

Running svgstore:dist from the below task (targeting the images folder that does not exist), fails with EACCES error:

svgstore: {
  options: {
    prefix: 'icon-'
  },
  app: {
    files: {
      '<%= config.app %>/images/svg-defs.svg': ['<%= config.app %>/images/svg/*.svg']
    }
  },
  dist: {
    files: {
      '<%= config.dist %>/images/svg-defs.svg': ['<%= config.app %>/images/svg/*.svg']
    }
  }
}

Error:

Running "svgstore:dist" (svgstore) task
Warning: Unable to create directory "/images" (Error code: EACCES). Use --force to continue.
Error: EACCES, permission denied '/images'
  at Object.fs.mkdirSync (fs.js:642:18)
  at /Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/grunt/file.js:200:12
  at Array.reduce (native)
  at Object.file.mkdir (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/grunt/file.js:195:34)
  at Object.file.write (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/grunt/file.js:287:8)
  at /Users/ain/Documents/projects/project-front-end/node_modules/grunt-svgstore/tasks/svgstore.js:171:24
  at Array.forEach (native)
  at Object.<anonymous> (/Users/ain/Documents/projects/project-front-end/node_modules/grunt-svgstore/tasks/svgstore.js:51:20)
  at Object.<anonymous> (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/grunt/task.js:264:15)
  at Object.thisTask.fn (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/grunt/task.js:82:16)
  at Object.jit.taskProxies.(anonymous function).fn (/Users/ain/Documents/projects/project-front-end/node_modules/jit-grunt/lib/jit-grunt.js:94:24)
  at Object.<anonymous> (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/util/task.js:301:30)
  at Task.runTaskFn (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/util/task.js:251:24)
  at Task.<anonymous> (/Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/util/task.js:300:12)
  at /Users/ain/Documents/projects/project-front-end/node_modules/grunt/lib/util/task.js:227:11
  at process._tickCallback (node.js:415:13)

IMHO, if the destination folder does not exist, it should be created, like it's handled by the other Grunt tasks.

Platform:

node v0.10.26
grunt-cli v0.1.13
grunt v0.4.5

Using in CSS

Maybe I'm missing the obvious, but I'm having trouble using the svg sprite file in my css. It works great in html with but I can't get the icons to show up in css.

I can reference the original svg files directly in css and they work as expected, but the svg sprite returns nothing.

Example use // CSS
This is how I expect it to work, but is blank.

.icon-heart {
  background: url('path/to/icons.svg#icon-heart');
}

using url('path/to/icon.svg') is also blank

Ideas? How are you guys using the svg sprite file with your css? Maybe this isn't possible?

Putting the svg sprite inside an html file instead of an svg file

I think the perfect scenario would be to combine this with the way Polymer handles their web component <core-icon>. The only drawback with the core-icon is that you have to create your svg sprite in an html file. Getting something like svgstore to spit the svg sprite into an html file(web component) would be an awesome workflow.

Anyone up for the challenge?

Relevant stackoverflow question and answers:
http://stackoverflow.com/questions/27158884/how-can-i-make-polymer-treat-my-custom-icons-the-same-as-their-own#answer-27164186

Little misleading docs

Hello, thanks for the plugin!

Trying to make everything works in my installation I found a little quirk in the project Readme.
In the cleanup option:

Clean up all inline style definitions that may jeopardise later stylesheet-based colouring (fill)

That fill in parenthesis lead me to think that fill was the element removed enabling that option. Not a big thing, but I had to look at source code to understand why it wasn't removed! ( and the problem has been solved passing an array )

Can you please update it and specify a little better the style is the element removed setting cleanup to true? :)

Thanks for your work! :)

Can't specify files for task: "File [no files]"

I really like the concept of this plugin but I've been unable to run it.

In my Gruntfile.js I have (along with various other Grunt tasks)

svgstore: {
  options: {
    prefix : 'icon-'
  },
  files: {
    'assets/icons.svg': ['img-src/icons/*.svg']
  }
}

Nothing fancy. There are corresponding img-src/icons/[foo,bar, etc.].svg files.

Running the task produces "Done, without errors." yet no icons.svg. Running in verbose mode I noticed:

Verifying property svgstore.files exists in config...OK
File: [no files]

So any advice working out why my files aren't being read in?

Thanks

ID's being changed

I have an SVG of the Flickr logo to which I added an ID to each circle so I could fill them via CSS later.

When using SVGStore it seems to change the ID's

My id that was set on one circle was left and svgstore has changed it to svgstore4774e1d17249478ca0e984fea77cc9f4left

Why has it done this and how can I keep my original id's?

I do not have the cleanup option enabled.

Thanks

issues with cleanup

cleanup removed the style from the svg tag but some time the styles like " fill " are in and tag also which is not removed. is there any way to do that ?

Option to add class to container `<svg>` tag in generated file

Unless I'm missing a step, doing a <?php include() results in the contents of the compiled SVG file being displayed on the page where it is included.

Having the option to add a class to the <svg> container in the output file would save the (minor) inconvenience of adding this manually with each run of the task.

For example, here's how Chris Coyier does it in the Codepen example accompanying his blog post:

<svg class="hide"><defs> 
  <g id="shape-codepen">

can't install... 'npm ERR! peerinvalid'

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!

npm ERR! System Darwin 13.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-svgstore" "--save-dev"
npm ERR! cwd /Users/jynk/Projects/619 Social Market Foundation/website/smf/wp-content/themes/smf-master
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/jynk/Projects/619 Social Market Foundation/website/smf/wp-content/themes/smf-master/npm-debug.log
npm ERR! not ok code 0

Add a class to each symbol

Hi,

Would it be possible to generate a class for each symbol?
In a similar way you do it to add the prefix to each ID.
I think it would be useful to target specific items and avoid styling with IDs.

What do you think?

Can't combine file

Hi,

Dont know anything wrong or changes, i tried and it run the plugin fine but it does not find the svg files (Can see the null file list the svstore read [] i use by the console.log [])

grunt-01
grunt-02

Nothing being created

I'm quite new to Grunt, but loving it already. After seeing Chris´s video about svgstore I can't wait to use it... But I'm having problems getting it to work.

Here is my config for svgstore:
image

This is what I get when running the task:
image

But nothing happens/gets created. Any idea what could be wrong?

Tags not closed in generated SVG

If I have only one <path> element as the only child of SVG root, the generated svg will have <path d="..." id="..."> but no closing tag or trailing slash. I guess this is due to how cheerio handles non-html tags(?)

Issue with some svg icons starting from 0.1.0

Hey,

I just noticed that one of my icons was missing a part of it. (It was 2 s). I tested the versions and it stopped working when upgrading to 0.1.0.

Any ideas why? Its fine until 0.0.4. Please let me know what info you need.

Problems with Sketch

Maybe a Problem with SVGs from Sketch3. When i combine SVGs with SVGStore i get an invalid SVG Sprite. Combined the same Icons with grunt-svg-sprite the Sprite is valid.

For the test i didn't use SVG Min.

Combined SVG 1

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="327px" height="327px" viewBox="0 0 327 327" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <!-- Generator: Sketch 3.0.3 (7892) - http://www.bohemiancoding.com/sketch -->
    <title>Slice 1</title>
    <desc>Created with Sketch.</desc>
    <defs></defs>
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
        <path d="M163.5,327 C253.798557,327 327,253.798557 327,163.5 C327,73.2014434 253.798557,0 163.5,0 C73.2014434,0 0,73.2014434 0,163.5 C0,253.798557 73.2014434,327 163.5,327 Z M101.5,145 C118.89697,145 133,130.89697 133,113.5 C133,96.1030304 118.89697,82 101.5,82 C84.1030304,82 70,96.1030304 70,113.5 C70,130.89697 84.1030304,145 101.5,145 Z M224.5,145 C241.89697,145 256,130.89697 256,113.5 C256,96.1030304 241.89697,82 224.5,82 C207.10303,82 193,96.1030304 193,113.5 C193,130.89697 207.10303,145 224.5,145 Z M163.5,287 C216.795478,287 260,265.509668 260,239 C260,212.490332 216.795478,191 163.5,191 C110.204522,191 67,212.490332 67,239 C67,265.509668 110.204522,287 163.5,287 Z" id="Oval-1" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
    </g>
</svg>

Combined SVG 2

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="538px" height="429px" viewBox="0 0 538 429" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
    <!-- Generator: Sketch 3.0.3 (7892) - http://www.bohemiancoding.com/sketch -->
    <title>Rectangle 1</title>
    <desc>Created with Sketch.</desc>
    <defs></defs>
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
        <path d="M463.418769,116 L531.000924,116 C534.874254,116 538,119.131711 538,122.994873 L538,422.005127 C538,425.864082 534.866407,429 531.000924,429 L6.9990758,429 C3.12574632,429 0,425.868289 0,422.005127 L0,122.994873 C0,119.135918 3.13359297,116 6.9990758,116 L73.407817,116 L106.357259,8.61307007 C107.817263,3.85470854 113.027611,0 117.99592,0 L414.00408,0 C418.972653,0 424.326925,3.80821248 425.963769,8.50588065 L463.418769,116 L463.418769,116 Z M269.5,409 C347.096007,409 410,346.096007 410,268.5 C410,190.903993 347.096007,128 269.5,128 C191.903993,128 129,190.903993 129,268.5 C129,346.096007 191.903993,409 269.5,409 Z M269.5,383 C332.736604,383 384,331.736604 384,268.5 C384,205.263396 332.736604,154 269.5,154 C206.263396,154 155,205.263396 155,268.5 C155,331.736604 206.263396,383 269.5,383 Z" id="Rectangle-1" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
    </g>
</svg>

Result

<svg viewBox="0 0 100 100"><symbol viewBox="0 0 538 429" id="bcam"><title>Rectangle 1</title><desc>Created with Sketch.</desc> <!-- Generator: Sketch 3.0.3 (7892) - http://www.bohemiancoding.com/sketch -->    <g id="svgstore6b7b9ce14f55c0e5a5968e00977f20eePage-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <path d="M463.418769,116 L531.000924,116 C534.874254,116 538,119.131711 538,122.994873 L538,422.005127 C538,425.864082 534.866407,429 531.000924,429 L6.9990758,429 C3.12574632,429 0,425.868289 0,422.005127 L0,122.994873 C0,119.135918 3.13359297,116 6.9990758,116 L73.407817,116 L106.357259,8.61307007 C107.817263,3.85470854 113.027611,0 117.99592,0 L414.00408,0 C418.972653,0 424.326925,3.80821248 425.963769,8.50588065 L463.418769,116 L463.418769,116 Z M269.5,409 C347.096007,409 410,346.096007 410,268.5 C410,190.903993 347.096007,128 269.5,128 C191.903993,128 129,190.903993 129,268.5 C129,346.096007 191.903993,409 269.5,409 Z M269.5,383 C332.736604,383 384,331.736604 384,268.5 C384,205.263396 332.736604,154 269.5,154 C206.263396,154 155,205.263396 155,268.5 C155,331.736604 206.263396,383 269.5,383 Z" id="svgstore6b7b9ce14f55c0e5a5968e00977f20eeRectangle-1" fill="#D8D8D8" sketch:type="MSShapeGroup"/> </g> </symbol><symbol viewBox="0 0 327 327" id="bsmilie"><title>Slice 1</title><desc>Created with Sketch.</desc> <!-- Generator: Sketch 3.0.3 (7892) - http://www.bohemiancoding.com/sketch -->    <g id="svgstore484675889306b2e1d6971a57964bf9afPage-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <path d="M163.5,327 C253.798557,327 327,253.798557 327,163.5 C327,73.2014434 253.798557,0 163.5,0 C73.2014434,0 0,73.2014434 0,163.5 C0,253.798557 73.2014434,327 163.5,327 Z M101.5,145 C118.89697,145 133,130.89697 133,113.5 C133,96.1030304 118.89697,82 101.5,82 C84.1030304,82 70,96.1030304 70,113.5 C70,130.89697 84.1030304,145 101.5,145 Z M224.5,145 C241.89697,145 256,130.89697 256,113.5 C256,96.1030304 241.89697,82 224.5,82 C207.10303,82 193,96.1030304 193,113.5 C193,130.89697 207.10303,145 224.5,145 Z M163.5,287 C216.795478,287 260,265.509668 260,239 C260,212.490332 216.795478,191 163.5,191 C110.204522,191 67,212.490332 67,239 C67,265.509668 110.204522,287 163.5,287 Z" id="svgstore484675889306b2e1d6971a57964bf9afOval-1" fill="#D8D8D8" sketch:type="MSShapeGroup"/> </g> </symbol></svg>

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.