fix(nuxi): only watch `distDir` after first build (#22614)

This commit is contained in:
Ryota Watanabe 2023-08-14 06:24:16 +09:00 committed by GitHub
parent 817c12f026
commit 4e409614e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -134,11 +134,6 @@ export default defineNuxtCommand({
await currentNuxt.ready()
distWatcher = chokidar.watch(resolve(currentNuxt.options.buildDir, 'dist'), { ignoreInitial: true, depth: 0 })
distWatcher.on('unlinkDir', () => {
dLoad(true, '.nuxt/dist directory has been removed')
})
const unsub = currentNuxt.hooks.hook('restart', async (options) => {
unsub() // we use this instead of `hookOnce` for Nuxt Bridge support
if (options?.hard) { return hardRestart() }
@ -156,6 +151,12 @@ export default defineNuxtCommand({
writeTypes(currentNuxt).catch(console.error),
buildNuxt(currentNuxt)
])
distWatcher = chokidar.watch(resolve(currentNuxt.options.buildDir, 'dist'), { ignoreInitial: true, depth: 0 })
distWatcher.on('unlinkDir', () => {
dLoad(true, '.nuxt/dist directory has been removed')
})
currentHandler = toNodeListener(currentNuxt.server.app)
if (isRestart && args.clear !== false) {
showBanner()