diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts index 71008a8cd2..111933165c 100644 --- a/packages/cli/src/commands/dev.ts +++ b/packages/cli/src/commands/dev.ts @@ -15,14 +15,13 @@ export async function invoke (args) { const { loadNuxt, buildNuxt } = requireModule('@nuxt/kit', rootDir) - const watcherFiles = new Set() - const watcher = chokidar.watch([rootDir], { ignoreInitial: true, depth: 0 }) - let currentNuxt const load = async () => { try { + showBanner(true) + listener.showURL() + const newNuxt = await loadNuxt({ rootDir, dev: true, ready: false }) - watcherFiles.add(newNuxt.options.watch) let configChanges if (currentNuxt) { @@ -37,9 +36,6 @@ export async function invoke (args) { currentNuxt = newNuxt } - showBanner(true) - listener.showURL() - if (configChanges) { if (configChanges.length) { info('Nuxt config updated:') @@ -60,9 +56,12 @@ export async function invoke (args) { } } + // Watch for config changes + // TODO: Watcher service, modules, and requireTree const dLoad = debounce(load, 250) + const watcher = chokidar.watch([rootDir], { ignoreInitial: true, depth: 1 }) watcher.on('all', (_event, file) => { - if (watcherFiles.has(file) || file.includes('nuxt.config')) { + if (file.includes('nuxt.config') || file.includes('modules')) { dLoad() } })