In gulp version 4 should I now use series() instead of pipe()? For example; my v3 task is below, should I change it to the last bit of code I've pasted? Is that the new gulp v4 way of doing things?
gulp.task('mytask', function() {
return gulp.src([
'scripts/a.js',
'scripts/b.js',
'scripts/c.js',
])
.pipe(concat('all.js'))
.pipe(gulp.dest('./scripts'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./scripts'));
});
New v4 way???
gulp.task('mytask', function() {
return gulp.src([
'scripts/a.js',
'scripts/b.js',
'scripts/c.js',
])
.series(
concat('all.js'),
gulp.dest('./scripts'),
rename('all.min.js'),
uglify(),
gulp.dest('./scripts')
);
});
In Gulp 4,
seriesis used to run multiple tasks one after another, whereaspipeis used to transform a stream within a single task.So you would change your task code to look like the following. The updated code returns a stream made with
srcandpiped through some transformations.There are various ways you can make functions that are tasks. See the docs here for more information.
Once you've got several tasks created you can compose them with
seriesorparallel. See here for more information on composing multiple tasks together.