問題描述
我一直在將我所有的 gulp v3 代碼庫遷移到 v4.但是我被困在我有 gulp start 功能的地方,當我在 gulp v4 中運行 gulp start 時它會拋出一個錯誤.
I have been migrating all of my gulp v3 code bases into v4. However I'm stuck at a point where I have gulp start function and it throws me an error when I run gulp start in gulp v4.
這是我在版本 3 中的功能:
This is the function I had in version 3:
gulp.task('default', ['watch'], function () {
gulp.start('styles', 'scripts', 'images');
});
當遷移到 gulp v4 時,我實現了這個功能:
When migrating to v4 of gulp I implemented this function:
gulp.task('default', gulp.parallel('watch', function(done) {
gulp.start('styles', 'scripts', 'images');
done();
}));
如何使用新的 gulp 版本完成相同的過程?我需要在 gulp.series
中使用 gulp.parallel
嗎?
How to accomplish the same process with the new gulp version? Do I need to use gulp.parallel
inside gulp.series
?
推薦答案
把你的任務改成函數后,簡單使用;
After changing your tasks to functions, simply use;
gulp.task('default', gulp.series (watch, gulp.parallel(styles, scripts, images),
function (done) { done(); }
));
watch 函數將首先運行,然后是樣式、腳本和圖像函數并行運行.
The watch function will run first, then the styles, scripts and images functions in parallel.
來自 gulp.series 文檔:
組合的嵌套深度沒有強加限制使用 series() 和 parallel() 進行操作.
There are no imposed limits on the nesting depth of composed operations using series() and parallel().
這篇關于將 gulp.start 函數遷移到 Gulp v4的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!