diff --git a/packages/nuxt/src/app/config.ts b/packages/nuxt/src/app/config.ts index 476f828abf..4a677359cd 100644 --- a/packages/nuxt/src/app/config.ts +++ b/packages/nuxt/src/app/config.ts @@ -54,6 +54,13 @@ export function useAppConfig (): AppConfig { return nuxtApp._appConfig } +export function _replaceAppConfig (newConfig: AppConfig) { + const appConfig = useAppConfig() + + deepAssign(appConfig, newConfig) + deepDelete(appConfig, newConfig) +} + /** * Deep assign the current appConfig with the new one. * diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index a42e141637..15da3975cd 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -425,7 +425,7 @@ export const appConfigTemplate: NuxtTemplate = { write: true, getContents ({ app, nuxt }) { return ` -import { updateAppConfig } from '#app/config' +import { _replaceAppConfig } from '#app/config' import { defuFn } from 'defu' const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)} @@ -433,7 +433,7 @@ const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)} // Vite - webpack is handled directly in #app/config if (import.meta.hot) { import.meta.hot.accept((newModule) => { - updateAppConfig(newModule.default) + _replaceAppConfig(newModule.default) }) }