Using SVGO options
DavidOliver opened this issue ยท 5 comments
I'd like to have the output XML pretty printed by using SVGO's pretty
option. Is it currently possible to do that with gulp-svgmin?
I see that plugins can be disabled but I haven't found anything for SVGO options.
Hi @DavidOliver,
No, it's not currently possible. The options object is constructed from the array of plugins to be enabled/disabled, so at the moment no other option is passed through to SVGO. However, I didn't consider this use case so I'm open to changing the API for gulp-svgmin to support it. Should be a simple fix. ๐
Hi @ben-eb,
Oh, that would be great - thanks!
Published the change as 1.0.0
on npm. For the pretty
option to work, you'll need to do this:
var svgmin = require('gulp-svgmin');
gulp.task('pretty', function() {
return gulp.src('test.svg')
.pipe(svgmin({
js2svg: {
pretty: true
}
}))
.pipe(gulp.dest('out'))
});
Thanks for the heads up! ๐
Wow, that was quick. Thanks again!
It's working, though it's not quite as pretty as I was expecting, with line breaks that I would expect missing. But I believe that's entirely an SVGO thing. It's much better to have some line breaks than none in my case. :-)
Congratulations on your 1.0.0 release.
Thanks! Yeah, will be a SVGO thing; open an issue upstream if you have any problems with it. ๐