运行 gulp.series() 中的问题

Issue in running gulp.series()

我的任务是在生产中缩小 JS 文件

function scriptsToMinify() {
 if(require('yargs').argv.production)
 {
  return gulp.src(src.JSFile)
  .pipe(sourcemaps.init())
  .pipe(ngAnnotate(
    {
      remove: true,
      add: true,
      single_quotes: true
    }))
  .pipe(concat('app.min.js'))
  .pipe(uglify())
  .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
  .pipe(sourcemaps.write())
  .pipe(gulp.dest('public'));
 }
}

当我 运行 在本地时它不 运行 依赖任务

gulp.task('inject-scripts', gulp.series(scriptsToMinify, function() {

  var thridPartyScripts = gulp.src(src.thirdPartyJS, { read: false })      
  var scripts = gulp.src([src.app_js, src.directiveJS], { read: false })

  return gulp.src('views/index.html')
.pipe(inject(series(thridPartyScripts, scripts))) // Inject files in an order to run the application without any dependency error.
.pipe(cachebust({ // Add the timestamp to the injected files to avoid cache issue
  type: 'timestamp'
}))
.pipe(gulp.dest('views'));
});

上述任务使我出错。

 The following tasks did not complete: default, inject-scripts, scriptsToMinify
 Did you forget to signal async completion?

将您的 scriptsToMinify 任务更改为

function scriptsToMinify(done) {
 if(require('yargs').argv.production)
 {
  return gulp.src(src.JSFile)
  .pipe(sourcemaps.init())
  .pipe(ngAnnotate(
    {
      remove: true,
      add: true,
      single_quotes: true
    }))
  .pipe(concat('app.min.js'))
  .pipe(uglify())
  .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
  .pipe(sourcemaps.write())
  .pipe(gulp.dest('public'));
 }
else{
  done();
}
}

当任务完成时你必须return发出信号,所以你必须传递回调。