Вот пример:
var gulp = require('gulp'),
imageMin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant');
gulp.task('images', function() {
return gulp.src(src.images)
.pipe(imageMin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()],
interlaced: true
}))
.pipe(gulp.dest(outputDir + 'img'))
.pipe(connect.reload())
});
результат:
[11:32:31] Using gulpfile ~/Dropbox/Projects/Work2016/mars/gulpfile.js
[11:32:31] Starting 'images'...
[11:32:54] gulp-imagemin: Minified 89 images (saved 3.85 MB - 37.4%)
[11:32:54] Finished 'images' after 23 s