Mario Parra
Mario Parra

Reputation: 1554

imagemin not minifying SVGs

I'm using imagemin with Grunt and it works as expected with PNGs/JPGs, but not with SVGs.

When I add an SVG into my project, Grunt says:

>> File "../public/microsite/src/img/Sketch.svg" added.
Running "imagemin:dynamic" (imagemin) task
Minified 0 images (saved 0 B)

Is this simply because it can't optimise them any further, or because it's not trying to at all? Even if an SVG can't be optimised, which I doubt is the case, I'd still like it imagemin to place it in the dist folder.

This is my config:

imagemin: {
    dynamic: {
        options: {
            optimizationLevel: 3,
            svgoPlugins: [{ removeViewBox: false }]
        },
        files: [{
            expand: true,
            cwd: '../public/microsite/src/img/',
            src: ['*.{png, jpg, svg}'],
            dest: '../public/microsite/build/img/'
        }]
    }
}

Upvotes: 0

Views: 161

Answers (1)

Mario Parra
Mario Parra

Reputation: 1554

I figured out the spaces in the src object were invalid. I removed them, which allowed all image files to be minified. src: ['*.*'] also works.

Upvotes: 0

Related Questions