Reputation:
I just installed svgo and then svgmin with grunt. Instead of minifying my code, when I run the svgmin command it just outputs a 0 kb file with no content. The task itself is registered in my gruntfile and runs successfully in the console.
My gruntfile has this function...
svgmin: { //minimize SVG files
options: {
plugins: [
{ removeViewBox: false },
{ removeUselessStrokeAndFill: false }
]
},
dist: {
expand: true,
cwd: 'main/svg',
src: ['*.svg'],
dest: 'main/svg',
ext: '.success.svg'
}
},
What am I doing wrong?
Upvotes: 1
Views: 331
Reputation: 613
I was having the same problem, the solution is quite easy actually. You just need to set the plugin cleanupIDs
to false
:
options: {
plugins: [
{ cleanupIDs: false },
{ removeViewBox: false },
{ removeUselessStrokeAndFill: false }
]
},
It seems that the cleanupIDs
plugin removes all groups (<g>
) and symbols (<symbol>
) that contain IDs, instead of just removing the IDs. Once you set it to false, you'll be grand.
Hope that helps.
Upvotes: 1