T
T
Taverna-MO2018-03-25 17:53:38
JavaScript
Taverna-MO, 2018-03-25 17:53:38

Gulp task runs 3 times, why?

Good afternoon. There is such a task

gulp.task('img:build', function (cb) {
    return gulp.src(['./src/images/**/*.{png,jpg}', '!./src/images/sprites/**/*', '!./src/images/temp/**/*'])
  .pipe(tinypng({
    key: path.tiny,
    sigFile: '.tinypng-sigs',

        summarise: true
    }))
  .pipe(plumber())
  .pipe(gulp.dest(path.build.img));
});

And yesterday
gulp.task('watch', function () {
  watch(['./src/images/**/*.{png,jpg}', '!./src/images/temp/**/*', '!./src/images/sprites/**/*'], function(event, cb) {
        gulp.start('img:build');
    });
});

When I transfer the image to the images folder for the first time, it works 1 time (because it compresses through tinypng, but if you delete the file and then throw it into the folder again, then it is no longer compressed (stored in the cache) and the task works 3 times
[16:59:09] Starting 'img:build'...
[16:59:09] gulp-tinypng-compress Skipped: 5 images, Compressed: 0 images, Savings: 0.00 B (ratio: 0)
[16:59:09] Finished 'img:build' after 49 ms
[16:59:10] Starting 'img:build'...
[16:59:10] gulp-tinypng-compress Skipped: 5 images, Compressed: 0 images, Savings: 0.00 B (ratio: 0)
[16:59:10] Finished 'img:build' after 9.89 ms
[16:59:10] Starting 'img:build'...
[16:59:10] gulp-tinypng-compress Skipped: 5 images, Compressed: 0 images, Savings: 0.00 B (ratio: 0)
[16:59:10] Finished 'img:build' after 6.41 ms

I can not understand what it could be connected with?
If you turn off compression through tinipng, nothing changes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Chernyshev, 2018-03-26
@IvanBlacky

What is the value of the variable path.build.img? Maybe watcher is watching this directory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question