This commit is contained in:
jinmao88
2023-08-10 15:52:57 +08:00
parent c99ef68b7b
commit 9650122736
2 changed files with 2 additions and 6 deletions

View File

@@ -27,8 +27,8 @@ async function createAppConfigPlugin({
return { return {
name: PLUGIN_NAME, name: PLUGIN_NAME,
async configResolved(_config) { async configResolved(_config) {
let appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? ''; const appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? '';
appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_'); // appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_');
publicPath = _config.base; publicPath = _config.base;
source = await getConfigSource(appTitle); source = await getConfigSource(appTitle);
}, },
@@ -82,7 +82,6 @@ const getVariableName = (title: string) => {
} }
return result.join('').toUpperCase(); return result.join('').toUpperCase();
} }
return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
}; };

View File

@@ -20,13 +20,10 @@ const getVariableName = (title: string) => {
} }
return result.join('').toUpperCase(); return result.join('').toUpperCase();
} }
return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
}; };
export function getAppEnvConfig() { export function getAppEnvConfig() {
console.log(import.meta.env.VITE_GLOB_APP_TITLE);
const ENV_NAME = getVariableName(import.meta.env.VITE_GLOB_APP_TITLE); const ENV_NAME = getVariableName(import.meta.env.VITE_GLOB_APP_TITLE);
console.log(ENV_NAME); console.log(ENV_NAME);
const ENV = import.meta.env.DEV const ENV = import.meta.env.DEV