w0rm / gulp-svgstore

Combine svg files into one with symbol elements
https://www.npmjs.com/package/gulp-svgstore
645 stars 33 forks source link

viewbox attribute being removed? #79

Closed nachtfunke closed 7 years ago

nachtfunke commented 7 years ago

This is the Code I am using:

gulp.task('svgstore', function() {
    return gulp.src(local.svg+'/singles/*.svg')
        pipe(svgmin({
            plugins: [{
                removeDoctype: true
            }, {
                removeXMLNS: true
            }, {
                removeXMLProcInst: true
            }, {
                removeComments: true
            }, {
                removeMetadata: true
            }, {
                removeEditorNSData: true
            }, {
                removeViewBox: false
            }]
        }))
        .pipe(cheerio(function ($, file) {
            $('[fill]').each(function() {
                if ( $(this).attr('fill') !== 'currentcolor' ) {
                    $(this).attr('fill', 'currentcolor');
                }
            });
        }))
        .pipe(svgstore())
        .pipe(gulp.dest(local.svg+'/sprites'));
});

And so far, everything works fine, BUT all my svg's are not scaleable because the viewbox attribute is being removed. Can someone explain to me, why this is happening, or if I just have some sort of wrong mindset about this?

w0rm commented 7 years ago

Hi! Svgstore should copy viewBox from a source svg to a corresponding symbol, tested here.

Have you tried removing svgmin and seeing if the issue is there?