I
I
Ilya Belsky2016-03-30 11:50:07
gulp.js
Ilya Belsky, 2016-03-30 11:50:07

caching for gulp-imagemin?

Welcome all! Can you tell me how to make gulp-imagemin compress only new images when I run it? Let's say I made a task:

//=======================================================
//                       Images
//=======================================================

gulp.task('img', function () {
    return gulp.src('./src/images/**')
        .pipe(plugins.debug())
        .pipe(plugins.imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()]
        }))
        .pipe(gulp.dest('./app/images/'));
});

It is necessary that the first time all images are compressed, and the next time when a new photo is added, only it is compressed, and not everything in the folder. The gulp-cached plugin didn't help, neither did the src option: {since: gulp.lastRun('img')}
Has anyone had this problem? If yes, how did you decide?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sizoider, 2016-03-31
@vik_kodik

you need to use https://www.npmjs.com/package/gulp-newer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question