Reputation: 8338
I'm using grunt-svgstore to merge SVG files. There's an option available called 'cleanup' (https://github.com/FWeinb/grunt-svgstore#optionscleanup) that should:
Clean up all inline style definitions that may jeopardise later stylesheet-based colouring (fill).
However, mine doesn't seem to work. The rest of it runs fine, I get the prefix and the viewBox and the file is created. It's just the cleanup that doesn't seem to work. Have I got the syntax wrong here (from my Gruntfile.js)?
svgstore: {
options: {
prefix: 'icon-',
cleanup: true,
svg: {
viewBox: '0 0 32 32',
class: 'is-hidden'
}
},
default: {
files: {
'svg/svg-sprite.svg': ['svg/*.svg']
}
}
}
Upvotes: 0
Views: 1295
Reputation: 51
It looks as though you can provide the 'cleanup' option with an array off attributes instead of just true
or false
. You can add the fill
attribute here in the array as well as style attribute if you wanted to.
options: {
cleanup: ['fill', 'style']
}
Hope this helps for future reference.
Upvotes: 5
Reputation: 8338
I was actually going down the wrong path with the question, but I'll leave it up for reference to anyone who runs into the same problem.
The plugin actually works perfectly as intended, which is to remove all inline styles:
<path style="fill:#000000:">
What it doesn't do is remove styles that are applied just using
<path fill="#000000">
The IcoMoon app that I was using to download my SVG icons colours the icons using the latter, and so the plugin won't remove those. Unfortunately, I had to go through each SVG individually and remove that fill="#000000"
.
Upvotes: 3