8

I am new to Gulp. I have two tasks:

gulp.task('jadehtml', function() {
  var YOUR_LOCALS = {};
  gulp.src('source/jade/*.jade')
    .pipe(jade({
      locals: YOUR_LOCALS,
      pretty: true
    }))
    .pipe(gulp.dest('build'))
});
// End Gulp Jade 

// default task

//  sass
gulp.task('sass', function () {
  return gulp.src('source/scss/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('build/css'));
});

Now they work perfectly fine when run individually. But when I use the gulp.watch() command they give me an error. Here is my watch task:

gulp.task('watch', function() {
  gulp.watch('source/jade/*.jade', 'jadehtml');
  gulp.watch('source/scss/*.scss', 'sass');
});

This is the error:

Error for Gulp

Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70
Cloudboy22
  • 1,496
  • 5
  • 21
  • 39

1 Answers1

29

The tasks parameter that you pass to gulp.watch() always has to be an array, even if it's just one task. So instead of this:

gulp.watch('source/jade/*.jade', 'jadehtml');
gulp.watch('source/scss/*.scss', 'sass');

You need to do this:

gulp.watch('source/jade/*.jade', ['jadehtml']);
gulp.watch('source/scss/*.scss', ['sass']);
Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70