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()
.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加