使用gulp.js我有三個任務(醜化,buildHTML,rmRevManifest)我想作爲父生成任務的一部分運行。代碼我有作品,除了它並行運行任務(即訂單不保留)。我如何才能完成任務,並在上一次完成前不運行下一個任務?Gulp.js運行的任務,在特定的順序阻斷
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.
的順序問題,並醜化應該首先運行,然後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\'.'));
});
這是有限的。例如,如果您有構建腳本的腳本任務,並且在某些情況下您首先要執行乾淨的任務。在gulp中你必須使'clean'成爲腳本的依賴。這具有清潔成爲強制性的效果。 – Henry