Difference between Gulp and Gulp series

Asked

Viewed 556 times

0

What’s the difference between using one or the other in Gulp v4?

Before I did something like gulp.task('default', ['build']);

But now of error...

AssertionError [ERR_ASSERTION]: Task function must be specified

1 answer

1


series() combines tasks and executes them one after the other in the specified order. Example:

const { series } = require('gulp');

function cleanDist(cb) {
  // task code...
}

function buildHTML(cb) {
  // task code...
}

exports.build = series(cleanDist, buildHTML);

This syntax using exports is part of the Gulp v4 recommendation.

The parallel serves to perform different tasks simultaneously: recommended for tasks that do not depend on each other.

Example:

const { parallel } = require('gulp');

function buildCSS(cb) {
  // task code...
}

function buildHTML(cb) {
  // task code...
}

exports.build = parallel(buildCSS, buildHTML);

You can also create composite tasks (put in a variable just as example, could call in Exports directly):

const { parallel, series } = require('gulp');

// funções ...

const buildProcess = series(cleanDist, parallel(buildCSS, buildHTML));
exports.default = buildProcess;

I recommend reading the documentation.

About the error which you have obtained, you can replace it with the syntax of the examples I have shown, or do it as follows:

gulp.task('default', gulp.{series|parallel});

The following post can also help you: https://fettblog.eu/gulp-4-parallel-and-series/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.