C. Kreutzer
C. Kreutzer

Reputation: 9

gulp.watch task crashes after first change

I'm new to gulp and i'm trying to watch jade and less files and clean the build directory before moving the new files. Somehow the task works for the first time i change a file and then it doesn't keep watching. I have found many different solutions but none of them worked for me. Here are my watch tasks:

gulp.task('watch', function() {
   gulp.watch(config.lessDir + '/**.less', ['css']);
   gulp.watch(config.jadeDir + '/**.jade', ['jade']);
});

gulp.task('jade', function() {
   del.sync(['build/**.html']);

   return gulp.src(config.jadeDir + '/**.jade')
   .pipe(jade({ pretty: true }))
   .pipe(gulp.dest('./build'));
});

gulp.task('css', function() {
   del.sync(['build/css/**.*']);

   return gulp.src(config.lessDir + '/**.less')
   .pipe(less())
   .pipe(gulp.dest('./build/css'))
   .pipe(minifyCSS())
   .pipe(extReplace('.min.css'))
   .pipe(gulp.dest('./build/css'));
});

With plumber i get the error "undefined is not a function".

Edit: Seems like del is not the problem but rather the pipelines handling the jade/less files.

Upvotes: 0

Views: 446

Answers (1)

C. Kreutzer
C. Kreutzer

Reputation: 9

For everyone having the same issue: gulp.watch only detects new or deleted files if you use relative paths. For example: use "less" instead of "./less". Now everything should work like a charm.

Upvotes: 1

Related Questions