Gulp error: watch task has to be a function

后端 未结 5 1063
花落未央
花落未央 2020-12-07 08:33

Here is my gulpfile:

// Modules & Plugins
var gulp = require(\'gulp\');
var concat = require(\'gulp-concat\');
var myth = require(\'gulp-myth\');
var ugl         


        
5条回答
  •  伪装坚强ぢ
    2020-12-07 08:55

    In gulp 3.x you could just pass the name of a task to gulp.watch() like this:

    gulp.task('watch', function() {
      gulp.watch('app/css/*.css', ['styles']);
      gulp.watch('app/js/*.js', ['scripts']);
      gulp.watch('app/img/*', ['images']);
    });
    

    In gulp 4.x this is no longer the case. You have to pass a function. The customary way of doing this in gulp 4.x is to pass a gulp.series() invocation with only one task name. This returns a function that only executes the specified task:

    gulp.task('watch', function() {
      gulp.watch('app/css/*.css', gulp.series('styles'));
      gulp.watch('app/js/*.js', gulp.series('scripts'));
      gulp.watch('app/img/*', gulp.series('images'));
    });
    

提交回复
热议问题