Dependency installation ( https://www.npmjs.com/package/gulp-imagemin )
$ npm install --save-dev gulp-imagemin
Usage
/*
* Your other dependencies.
*/
var imagemin = require('gulp-imagemin');
/*
* `gulp images` - Run lossless compression on all the images.
*/
gulp.task('images', function() {
return gulp.src(sourcePath) // e.g. /assets/images
.pipe(imagemin({
progressive: true,
interlaced: true,
svgoPlugins: [{removeUnknownsAndDefaults: false}, {cleanupIDs: false}]
}))
.pipe(gulp.dest(buildPath + 'images')); // e.g. /static/dist/
});