如何在javascript函数中运行一个接一个的gulp函数?

时间:2016-04-14 16:29:18

标签: javascript node.js gulp

这就是我现在所拥有的:

function make_exHtml(config) {

    gulp.src(config, { base: process.cwd() })
      .pipe(print(function (file) {
          return "Found file " + file;
      }))
      .pipe(rename({ basename: 'base' }))
      .pipe(gulp.dest('./'));

    return gulp.src(config.srcTemplates)
          .pipe(print(function (file) {
              return "Added file " + file + " to template";
          }))
       .pipe(minifyHTML({ collapseWhitespace: true }))
       .pipe(templateCache({ standalone: true, root: '/app' }))
       .pipe(gulp.dest(config.destPartials))
       .pipe(gzip(gzip_options))
       .pipe(gulp.dest(config.destPartials));
}

我需要做的是确保第一次吞咽在第二次之前运行。有人能告诉我怎么做吗?

1 个答案:

答案 0 :(得分:1)

您可以使用run-sequence。将make_exHtml拆分为两个任务

var runSequence = require('run-sequence');

gulp.task('make_exHtml', function(callback) {
  runSequence('first_task','second_task', function(){
    make_prod('xxx');
    callback();
  });
});
相关问题