升级到 gulp 4 后 gulp 手表出现问题
Problem with gulp watch after upgrading to gulp 4
与此问题相关 = Gulp error: The following tasks did not complete: Did you forget to signal async completion?
当我尝试使用以下代码 运行 "watch" 时出现错误:
gulp.task('watch', async function() {
var watchJs = gulp.watch(paths.js, ['scripts']),
watchJson = gulp.watch(paths.json, ['json']),
watchHtml = gulp.watch(paths.html, ['html']),
watchCss = gulp.watch(paths.css, ['css']),
watchFonts = gulp.watch(paths.fonts, ['fonts']),
watchAssets = gulp.watch(paths.assets, ['assets']),
onChanged = function(event) {
console.log('File ' + event.path + ' was ' + event.type + '. Running tasks...');
}
watchJs.on('change', onChanged);
watchJson.on('change', onChanged);
watchHtml.on('change', onChanged);
watchCss.on('change', onChanged);
watchFonts.on('change', onChanged);
watchAssets.on('change', onChanged);
});
错误说:Error: watching src/js/**/*.js: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
但我不知道如何处理这个问题。我尝试将异步设置为 gulp.task('watch', async function() { 但这没有用
改变
var watchJs = gulp.watch(paths.js, ['scripts']), // gulp v3 syntax
至
var watchJs = gulp.watch(paths.js, gulp.serie('scripts')), // gulp v4 syntax
和你的其他人一样。查找从 gulp v3 到 v4 的迁移指南。
与此问题相关 = Gulp error: The following tasks did not complete: Did you forget to signal async completion?
当我尝试使用以下代码 运行 "watch" 时出现错误:
gulp.task('watch', async function() {
var watchJs = gulp.watch(paths.js, ['scripts']),
watchJson = gulp.watch(paths.json, ['json']),
watchHtml = gulp.watch(paths.html, ['html']),
watchCss = gulp.watch(paths.css, ['css']),
watchFonts = gulp.watch(paths.fonts, ['fonts']),
watchAssets = gulp.watch(paths.assets, ['assets']),
onChanged = function(event) {
console.log('File ' + event.path + ' was ' + event.type + '. Running tasks...');
}
watchJs.on('change', onChanged);
watchJson.on('change', onChanged);
watchHtml.on('change', onChanged);
watchCss.on('change', onChanged);
watchFonts.on('change', onChanged);
watchAssets.on('change', onChanged);
});
错误说:Error: watching src/js/**/*.js: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
但我不知道如何处理这个问题。我尝试将异步设置为 gulp.task('watch', async function() { 但这没有用
改变
var watchJs = gulp.watch(paths.js, ['scripts']), // gulp v3 syntax
至
var watchJs = gulp.watch(paths.js, gulp.serie('scripts')), // gulp v4 syntax
和你的其他人一样。查找从 gulp v3 到 v4 的迁移指南。