我在终端中运行gulp服务,然后弹出窗口。但是,当我在.html中进行更改时,这些更改不会重新加载到页面上。我不知道什么是异步完成,因为这是我第一次收到此错误。
[BS] Local URL: http://localhost:3000
[BS] External URL: http://10.0.0.58:3000
[BS] Serving files from: temp
[BS] Serving files from: dev
[BS] Serving files from: dev/html
^C[15:49:48] The following tasks did not complete: serve
[15:49:48] Did you forget to signal async completion?
let serve = () => {
browserSync({
notify: true,
reloadDelay: 0, // A delay is sometimes helpful when reloading at the
server: { // end of a series of tasks.
baseDir: [
`temp`,
`dev`,
`dev/html`
]
}
});
watch(`dev/html/**/*.html`, series(validateHTML)).on(`change`, reload);
watch(`dev/js/*.js`, series(lintJS, compressJS)).on(`change`, reload);
watch (`dev/css/**/*.css`, series(compressCSS)) .on(`change`, reload);
};
答案 0 :(得分:0)
Gulp 4需要完成每个任务,以便它可以继续以指定的顺序(例如,并行或串行)运行其他任务。
您收到该致命错误,因为您的serve
任务缺少done
回调,该回调使gulp知道您已准备好开始队列中的下一个任务。
此处有更多信息:What does Gulp "done" method do?
以下是您的serve
任务的更新版本,它将使该任务继续并行运行而不会导致致命错误。
let serve = (done) => { // add done as an argument
browserSync({
notify: true,
reloadDelay: 0, // A delay is sometimes helpful when reloading at the
server: { // end of a series of tasks.
baseDir: [
'temp',
'dev',
'dev/html'
]
}
});
watch('dev/html/**/*.html', series(validateHTML)).on('change', reload);
watch('dev/js/*.js', series(lintJS, compressJS)).on('change', reload);
watch ('dev/css/**/*.css', series(compressCSS)) .on('change', reload);
done(); // call the done method when you are ready to move onto the next task.
};