Use gulp imagemin optimizers in combination with gulp-load-plugins

878 Views Asked by At

I'm using Gulp-load-plugins (https://github.com/jackfranklin/gulp-load-plugins) to require all my plugins automatically.

As in

// Load Gulp plugins
var plugins = require('gulp-load-plugins')();

Now to use imagemin, I have the following setup

// Imagemin
.pipe(plugins.imagemin({
    optimizationLevel: 3,
    progressive: true,
    svgoPlugins: [{
        removeViewBox: false
    }],
    interlaced: true,
    use: [plugins.svgo()]
}))

But I get the error "TypeError: Object # has no method 'svgo'". In the documentation of imagemin, they require the optimisers separately. Is this possible in combination with the grunt-load-plugins module? If so, how?

Thanks in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

I think that you should install imagemin-svgo plugin to get this work, because it is not included by default to gulp-imagemin like precised at the bottom line of the README.

Install it using npm:

npm install --save imagemin-svgo

And require it in your gulpfile since the gulp-load-plugins follow the gulp-* pattern and will not load it. And call it in the use options like you did before.