V
V
Vladimir Kashutin2016-11-17 12:39:14
gulp.js
Vladimir Kashutin, 2016-11-17 12:39:14

Why is gulp watch collecting files endlessly?

Hello, I ran into a problem: When you change the file 1.styl - watch starts to run endlessly. Compiled a basic example, but it refuses to work. gulp version - 4.0

const gulp   = require('gulp')
const stylus = require('gulp-stylus')

gulp.task('watch', function(){
    gulp.watch('./src/**/*.styl', gulp.parallel('build'));
});

gulp.task('build', function(){
  return gulp.src('./src/styl/1.styl')
  .pipe(stylus())
  .pipe(gulp.dest('./build'))
})

gulp.task('default', gulp.parallel('build', 'watch'))

Experimentally I was able to determine that if we replace
gulp.task('build', function(){
  return gulp.src('./src/styl/1.styl')
  .pipe(stylus())
  .pipe(gulp.dest('./build'))
})

on the
gulp.task('build', function(done){
  console.log('build');
  done();
})

that works. But
gulp.task('build', function(done){
  console.log(gulp.src('src/styl/1.styl'));
  done();
})

endless execution starts again

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei Nazarenko, 2016-11-23
@nazares

gulp.parallel('build', 'watch') this thing loops everything for you, but in fact the build and watch tasks do the same thing tobish build collects tsfesr looks at the changes and again collects as a result in a circle to infinity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question