mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(nuxt): use deep assignment for app.config hmr (#6788)
This commit is contained in:
parent
7e2fbcfb1d
commit
3b2b22e384
@ -20,9 +20,7 @@ if (process.dev) {
|
|||||||
function applyHMR (newConfig: AppConfig) {
|
function applyHMR (newConfig: AppConfig) {
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
if (newConfig && appConfig) {
|
if (newConfig && appConfig) {
|
||||||
for (const key in newConfig) {
|
deepAssign(appConfig, newConfig)
|
||||||
(appConfig as any)[key] = (newConfig as any)[key]
|
|
||||||
}
|
|
||||||
for (const key in appConfig) {
|
for (const key in appConfig) {
|
||||||
if (!(key in newConfig)) {
|
if (!(key in newConfig)) {
|
||||||
delete (appConfig as any)[key]
|
delete (appConfig as any)[key]
|
||||||
@ -31,6 +29,17 @@ if (process.dev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deepAssign (obj: any, newObj: any) {
|
||||||
|
for (const key in newObj) {
|
||||||
|
const val = newObj[key]
|
||||||
|
if (val !== null && typeof val === 'object') {
|
||||||
|
deepAssign(obj[key], val)
|
||||||
|
} else {
|
||||||
|
obj[key] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Vite
|
// Vite
|
||||||
if (import.meta.hot) {
|
if (import.meta.hot) {
|
||||||
import.meta.hot.accept((newModule) => {
|
import.meta.hot.accept((newModule) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user