Gulp does not minify images

Asked

Viewed 70 times

0

I need minify many images, but I’m not getting with the Gulp.

Problem: The Code minifica no image and I have checked that all images are in the folder.

Folder structure: Gulpfile is at the same level as the img folder and inside the folder has the images inside.

Console:

gulp-imagemin: Minified 0 images
Finished 'minify-img' after 4.06 s

Code:

// gulpfile.js
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');

gulp.task('minify-img', function () {
   return gulp.src('img/*')
   .pipe(imagemin())
   .pipe(gulp.dest('img/'))
}); 

Expected Result: Minify all images inside the folder img

  • What appears on the console?

  • Gulp-imagemin: Minified 0 images

  • Are you pointing to the right folder? How is the project folder structure?

  • Gulpfile is together with the img folder and inside the folder has the images inside.

  • have you tried other options?

  • see if the image path is correct: return gulp.src('img/*') => return gulp.src('./img/*')

  • if the gulpfile file is inside the folder img, it would be this case then: gulp.src('./*')

  • I’ll try other options, but I wanted to know what’s wrong since it seems to be following all the standards of Gulp.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.