initial commit
This commit is contained in:
56
node_modules/nuxt/dist/app/config.mjs
generated
vendored
Normal file
56
node_modules/nuxt/dist/app/config.mjs
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import { reactive } from "vue";
|
||||
import { useNuxtApp } from "./nuxt.mjs";
|
||||
import __appConfig from "#build/app.config.mjs";
|
||||
export const _getAppConfig = () => __appConfig;
|
||||
function deepDelete(obj, newObj) {
|
||||
for (const key in obj) {
|
||||
const val = newObj[key];
|
||||
if (!(key in newObj)) {
|
||||
delete obj[key];
|
||||
}
|
||||
if (val !== null && typeof val === "object") {
|
||||
deepDelete(obj[key], newObj[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function deepAssign(obj, newObj) {
|
||||
for (const key in newObj) {
|
||||
const val = newObj[key];
|
||||
if (val !== null && typeof val === "object") {
|
||||
deepAssign(obj[key], val);
|
||||
} else {
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
export function useAppConfig() {
|
||||
const nuxtApp = useNuxtApp();
|
||||
if (!nuxtApp._appConfig) {
|
||||
nuxtApp._appConfig = reactive(__appConfig);
|
||||
}
|
||||
return nuxtApp._appConfig;
|
||||
}
|
||||
export function updateAppConfig(appConfig) {
|
||||
const _appConfig = useAppConfig();
|
||||
deepAssign(_appConfig, appConfig);
|
||||
}
|
||||
if (process.dev) {
|
||||
let applyHMR = function(newConfig) {
|
||||
const appConfig = useAppConfig();
|
||||
if (newConfig && appConfig) {
|
||||
deepAssign(appConfig, newConfig);
|
||||
deepDelete(appConfig, newConfig);
|
||||
}
|
||||
};
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept((newModule) => {
|
||||
const newConfig = newModule._getAppConfig();
|
||||
applyHMR(newConfig);
|
||||
});
|
||||
}
|
||||
if (import.meta.webpackHot) {
|
||||
import.meta.webpackHot.accept("#build/app.config.mjs", () => {
|
||||
applyHMR(__appConfig);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user