Skip to content

Instantly share code, notes, and snippets.

@jarcoal
Created April 10, 2015 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarcoal/0f8d205598401baaf414 to your computer and use it in GitHub Desktop.
Save jarcoal/0f8d205598401baaf414 to your computer and use it in GitHub Desktop.
SVG Sprite Color
var svgColor = function(color) {
return function(shape, sprite, callback) {
var paths = shape.dom.getElementsByTagName('path');
for (var i = 0; i < paths.length; i++) {
paths[i].setAttribute('fill', color);
}
callback(null);
};
};
module.exports = function(grunt) {
grunt.initConfig({
svg_sprite: {
// ...
options: {
// svgo must appear in transform list
transform: ['svgo', {
// 'dark' can be changed for any value
dark: svgColor('#FFF')
}],
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment