diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index f5e8da57cd..1c725b0dc8 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -66,6 +66,8 @@ export default defineNuxtCommand({ }) let currentNuxt: Nuxt + let distWatcher: chokidar.FSWatcher + const showURL = () => { listener.showURL({ // TODO: Normalize URL with trailing slash within schema @@ -82,11 +84,20 @@ export default defineNuxtCommand({ if (currentNuxt) { await currentNuxt.close() } + if (distWatcher) { + await distWatcher.close() + } + currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false }) if (!isRestart) { showURL() } + distWatcher = chokidar.watch(resolve(currentNuxt.options.buildDir, 'dist'), { ignoreInitial: true, depth: 0 }) + distWatcher.on('unlinkDir', () => { + dLoad(true, '.nuxt/dist directory has been removed') + }) + // Write manifest and also check if we need cache invalidation if (!isRestart) { const previousManifest = await loadNuxtManifest(currentNuxt.options.buildDir)