From 19c3aa05311bf7c02fe1e8e695ad1a209aa43427 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 14 Feb 2024 16:03:20 +0100 Subject: [PATCH] fix(dev): support `.config/` dir and custom config extensions (#341) --- src/utils/dev.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/utils/dev.ts b/src/utils/dev.ts index 940ebfe5..5d732b9a 100644 --- a/src/utils/dev.ts +++ b/src/utils/dev.ts @@ -1,6 +1,6 @@ import type { RequestListener, ServerResponse } from 'node:http' import EventEmitter from 'node:events' -import { relative, resolve } from 'pathe' +import { relative, resolve, join } from 'pathe' import chokidar from 'chokidar' import { consola } from 'consola' import { debounce } from 'perfect-debounce' @@ -77,7 +77,9 @@ export async function createNuxtDevServer( return devServer } -const RESTART_RE = /^(nuxt\.config\.(js|ts|mjs|cjs)|\.nuxtignore|\.nuxtrc)$/ +// https://regex101.com/r/7HkR5c/1 +const RESTART_RE = + /^(nuxt\.config\.[a-z0-9]+|\.nuxtignore|\.nuxtrc|\.config\/nuxt(\.config)?\.[a-z0-9]+)$/ class NuxtDevServer extends EventEmitter { private _handler?: RequestListener @@ -281,10 +283,13 @@ class NuxtDevServer extends EventEmitter { } async _watchConfig() { - const configWatcher = chokidar.watch([this.options.cwd], { - ignoreInitial: true, - depth: 0, - }) + const configWatcher = chokidar.watch( + [this.options.cwd, join(this.options.cwd, '.config')], + { + ignoreInitial: true, + depth: 0, + }, + ) configWatcher.on('all', (_event, _file) => { const file = relative(this.options.cwd, _file) if (file === (this.options.dotenv || '.env')) {