【发布时间】:2014-07-09 18:58:29
【问题描述】:
使用 gulp.js 我有三个任务(uglify、buildHTML、rmRevManifest)我想作为父构建任务的一部分运行。我的代码可以工作,除了它并行运行任务(即不保留顺序)。如何让任务阻塞而不运行下一个直到前一个完成?
I.E.现在执行顺序返回为:
[11:50:17] gulp-notify: [Gulp notification] Deleted 'rev-manifest.json'.
[11:50:17] gulp-notify: [Gulp notification] Created 'build/index.html'.
[11:50:17] gulp-notify: [Gulp notification] Uglified JavaScript.
顺序很重要,uglify 应该首先运行,然后是 buildHTML,最后是 rmRevManifest。
gulp.task('build', ['uglify', 'buildHTML', 'rmRevManifest'], function(cb) {
});
gulp.task('uglify', function(cb) {
gulp.src('client/js/source/**/*.js')
.pipe(concat('app'))
.pipe(ngmin())
.pipe(uglify())
.pipe(rev())
.pipe(rename({
extname: ".min.js"
}))
.pipe(gulp.dest('client/js'))
.pipe(rev.manifest())
.pipe(gulp.dest('client/js'))
.pipe(notify('Uglified JavaScript.'));
});
gulp.task('buildHTML', function(cb) {
gulp.src('client/views/index.html')
.pipe(replace(/app\-[a-fA-F0-9]\.min\.js/, 'app-.min.js'))
.pipe(gulp.dest('client/build'))
.pipe(notify('Created \'build/index.html\'.'));
});
gulp.task('rmRevManifest', function(cb) {
gulp.src('client/js/rev-manifest.json', { read: false })
.pipe(rimraf())
.pipe(notify('Deleted \'rev-manifest.json\'.'));
});
【问题讨论】:
标签: javascript gulp