diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index d4fd7e6f85..2b73fc20b9 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -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()