Answer the question
In order to leave comments, you need to log in
How to correctly configure gulp-imagemin to satisfy the PageSpeed Insights requirement?
the task for minifying images looks trite
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const $ = gulpLoadPlugins();
...
...
...
gulp.task('images', () => {
return gulp.src('src/images/**/*')
.pipe($.cache($.imagemin({verbose: true})))
.pipe(gulp.dest('dist/images'));
});
...
Answer the question
In order to leave comments, you need to log in
Google just doesn't like the lossless option, give it optimization With loss of quality, alas... for these purposes I found for the same imagemin, the additions imageminJpegRecompress and imageminPngquant
after such a task:
// Таск для оптимизации изображений
gulp.task('img:prod', function () {
return gulp.src(path.src.img) //Выберем наши картинки
.pipe(debug({title: 'building img:', showFiles: true}))
.pipe(plumber(plumberOptions))
.pipe(gulp.dest(path.prod.img)) //Копируем изображения заранее, imagemin может пропустить парочку )
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imageminJpegRecompress({
progressive: true,
max: 80,
min: 70
}),
imageminPngquant({quality: '80'}),
imagemin.svgo({plugins: [{removeViewBox: true}]})
]))
.pipe(gulp.dest(path.prod.img)); //И бросим в prod отпимизированные изображения
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question