fix(nuxt): delete existing properties in app config HMR (#30918)

This commit is contained in:
Damian Głowala 2025-02-10 18:10:10 +01:00 committed by GitHub
parent 763450c93d
commit fc52ff8c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -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.
*

View File

@ -437,12 +437,12 @@ import { defuFn } from 'defu'
const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
/** client **/
import { updateAppConfig } from '#app/config'
import { _replaceAppConfig } from '#app/config'
// Vite - webpack is handled directly in #app/config
if (import.meta.dev && !import.meta.nitro && import.meta.hot) {
import.meta.hot.accept((newModule) => {
updateAppConfig(newModule.default)
_replaceAppConfig(newModule.default)
})
}
/** client-end **/