feat(nuxt): add chokidar watcher debug timing (#20176)

This commit is contained in:
Sacha Stafyniak 2023-04-11 14:19:45 +00:00 committed by GitHub
parent 163913a744
commit 811bf28068
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,10 @@ export async function build (nuxt: Nuxt) {
}
function watch (nuxt: Nuxt) {
if (nuxt.options.debug) {
console.time('[nuxt] builder:chokidar:watch')
}
const watcher = chokidar.watch(nuxt.options._layers.map(i => i.config.srcDir as string).filter(Boolean), {
...nuxt.options.watchers.chokidar,
cwd: nuxt.options.srcDir,
@ -55,6 +59,10 @@ function watch (nuxt: Nuxt) {
]
})
if (nuxt.options.debug) {
watcher.on('ready', () => console.timeEnd('[nuxt] builder:chokidar:watch'))
}
watcher.on('all', (event, path) => nuxt.callHook('builder:watch', event, normalize(path)))
nuxt.hook('close', () => watcher.close())
return watcher