mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-21 16:55:57 +00:00
fix(nuxt): delete existing properties in app config HMR (#30918)
This commit is contained in:
parent
31e72ded69
commit
3d0d831463
@ -54,6 +54,13 @@ export function useAppConfig (): AppConfig {
|
|||||||
return nuxtApp._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.
|
* Deep assign the current appConfig with the new one.
|
||||||
*
|
*
|
||||||
|
@ -425,7 +425,7 @@ export const appConfigTemplate: NuxtTemplate = {
|
|||||||
write: true,
|
write: true,
|
||||||
getContents ({ app, nuxt }) {
|
getContents ({ app, nuxt }) {
|
||||||
return `
|
return `
|
||||||
import { updateAppConfig } from '#app/config'
|
import { _replaceAppConfig } from '#app/config'
|
||||||
import { defuFn } from 'defu'
|
import { defuFn } from 'defu'
|
||||||
|
|
||||||
const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
|
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
|
// Vite - webpack is handled directly in #app/config
|
||||||
if (import.meta.hot) {
|
if (import.meta.hot) {
|
||||||
import.meta.hot.accept((newModule) => {
|
import.meta.hot.accept((newModule) => {
|
||||||
updateAppConfig(newModule.default)
|
_replaceAppConfig(newModule.default)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user