Task dependencies
When creating tasks, you might encounter a scenario in which you will need to ensure that a series of tasks run in a specific order.
As mentioned in the earlier chapters, the solution to this problem will differ based on which version of gulp you are using. Version 4.x introduces the .series
method, which allows us to specify the order in which our tasks need to be executed directly whereas version 3.x requires us to specify the dependency in each of our task assignments.
To better understand this, take a look at an example using version 3.x.
For version 3.x, refer to the following code:
// Styles Task gulp.task('styles', ['clean'], function () { gulp.src('app/css/*.css') .pipe(plumber({ errorHandler: onError })) .pipe(concat('all.css')) .pipe(postcss([ cssnext(), cssnano() ])) .pipe(gulp.dest('dist')); });
As you can see in this example, we will provide the clean
task...