gulp.run is deprecated. How do I compose tasks?

后端 未结 10 1240
感情败类
感情败类 2020-12-22 18:57

Here is a composed task I don\'t know how to replace it with task dependencies.

...
gulp.task(\'watch\', function () {
 var server = function(){
  gulp.run(\         


        
10条回答
  •  春和景丽
    2020-12-22 19:37

    If you need to maintain the order of running tasks you can define dependencies as described here - you just need to return stream from the dependency:

    gulp.task('dependency', function () {
      return gulp.src('glob')
        .pipe(plumber())
        .pipe(otherPlugin())
        .pipe(gulp.dest('destination'));
    });
    

    Define the task that depends on it:

    gulp.task('depends', [ 'dependency' ], function () {
      // do work
    });
    

    And use it from watch:

    gulp.task('watch', function () {
      watch('glob', [ 'depends' ]);
    });
    

    Now the dependecy task will complete before depends runs (for example your 'jasmine' and 'embed' tasks would be dependencies and you'd have another task 'server' that would depend on them). No need for any hacks.

提交回复
热议问题