Gulp task formed like this (without return
) runs much faster:
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less())
.pipe(gulp.dest('./destination'));
});
than the same one with return
:
gulp.task('less', function () {
return gulp.src('./less/**/*.less')
.pipe(less())
.pipe(gulp.dest('./destination'));
});
So, my question is what does Gulp task is supposed to return
? Why is it so much faster without return
, while it still generates expected files?
After some investigation I found that when return
is used on Gulp task it's not actually slower at all, it just returns correct time it took to finish the task.
It only felt faster since without return
statement it essentially returned result as completed almost instantly, so the task time looked like few ms, but the actual process continued on the background and completed silently.
So, it's safe to say that it's prefferable to use return
on all your tasks that have gulp.src()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.