How to perform gulp tasks sequentially?

I have several tasks in gulp, and all of them except that you can run in parallel. Consider an example:

var gulp = require('gulp'); gulp.task('clean', function() { // clean up output folder }); gulp.task('copy1', function() { // writes stream in the output folder }); gulp.task('copy2', function() { // writes stream in the output folder }); gulp.task('default', ['clean', 'copy1', 'copy2']); 

In this example, I need to run copy1 and copy2 in parallel, but only after clean . How can I do this trick?

+6
source share
2 answers
 var runSequence = require('run-sequence'); gulp.task('default', function(callback) { runSequence('clean', ['copy1', 'copy2'], callback); }); 
+5
source

Be careful . There is a bug in gulp 3.x. Even when using runSequence, the stream will return prematurely when the file is involved. Check out this post if you have problems:

+5
source

Source: https://habr.com/ru/post/984351/


All Articles