Answer the question
In order to leave comments, you need to log in
Why doesn't gulp-imagemin compress images?
Good evening everyone.
Please tell me why gulp-imagemin gives:
[19:23:51] Using gulpfile /var/www/www-root/data/www/site-name.ru/gulpfile.js
[19:23:51] Starting 'compress'...
[19:23:51] gulp-imagemin: Minified 0 images
[19:23:51] The following tasks did not complete: compress
[19:23:51] Did you forget to signal async completion?
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
gulp.task('compress', function() {
gulp.src('/var/www/www-root/data/www/site-name.ru/assets/images/*')
.pipe(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true }))
.pipe(gulp.dest('/var/www/www-root/data/www/site-name.ru/app/img'))
});
Answer the question
In order to leave comments, you need to log in
The text of the error is easily googled and will inevitably lead to the documentation https://gulpjs.com/docs/en/getting-started/async-c...
As a result, you either need to call the callback function following the example of akavato or return stream
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
gulp.task('compress', function() {
return gulp.src('assets/images/*')
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 7})
]))
.pipe(gulp.dest('app/img'))
});
gulp.task('compress', function(done) {
gulp.src('/var/www/www-root/data/www/site-name.ru/assets/images/*')
.pipe(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true }))
.pipe(gulp.dest('/var/www/www-root/data/www/site-name.ru/app/img'))
done();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question