mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 02:01:30 +08:00
perf: optimize the diffPreferences logic and adjust the unit test (#4130)
This commit is contained in:
@@ -25,6 +25,9 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* importmap CDN 暂时不开启,因为有些包不支持,且网络不稳定
|
||||
*/
|
||||
const defaultImportmapOptions: ImportmapPluginOptions = {
|
||||
// 通过 Importmap CDN 方式引入,
|
||||
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
|
||||
|
@@ -80,7 +80,7 @@ async function viteImportMapPlugin(
|
||||
const firstLayerKeys = Object.keys(scopes);
|
||||
const inputMapScopes: string[] = [];
|
||||
firstLayerKeys.forEach((key) => {
|
||||
inputMapScopes.push(...Object.keys(scopes[key]));
|
||||
inputMapScopes.push(...Object.keys(scopes[key] || {}));
|
||||
});
|
||||
const inputMapImports = Object.keys(imports);
|
||||
|
||||
@@ -160,7 +160,10 @@ async function viteImportMapPlugin(
|
||||
options.defaultProvider || DEFAULT_PROVIDER,
|
||||
);
|
||||
|
||||
const resultHtml = await injectShimsToHtml(html, esModuleShimsSrc);
|
||||
const resultHtml = await injectShimsToHtml(
|
||||
html,
|
||||
esModuleShimsSrc || '',
|
||||
);
|
||||
html = await minify(resultHtml || html, {
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true,
|
||||
|
@@ -16,8 +16,8 @@ function resolvePackageVersion(
|
||||
async function resolveMonorepoDependencies() {
|
||||
const { packages } = await getPackages();
|
||||
|
||||
const resultDevDependencies: Record<string, string> = {};
|
||||
const resultDependencies: Record<string, string> = {};
|
||||
const resultDevDependencies: Record<string, string | undefined> = {};
|
||||
const resultDependencies: Record<string, string | undefined> = {};
|
||||
const pkgsMeta: Record<string, string> = {};
|
||||
|
||||
for (const { packageJson } of packages) {
|
||||
|
@@ -6,6 +6,14 @@ import { fs } from '@vben/node-utils';
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
const getBoolean = (value: string | undefined) => value === 'true';
|
||||
|
||||
const getString = (value: string | undefined, fallback: string) =>
|
||||
value ?? fallback;
|
||||
|
||||
const getNumber = (value: string | undefined, fallback: number) =>
|
||||
Number(value) || fallback;
|
||||
|
||||
/**
|
||||
* 获取当前环境下生效的配置文件名
|
||||
*/
|
||||
@@ -63,6 +71,7 @@ async function loadAndConvertEnv(
|
||||
} & Partial<ApplicationPluginOptions>
|
||||
> {
|
||||
const envConfig = await loadEnv(match, confFiles);
|
||||
|
||||
const {
|
||||
VITE_APP_TITLE,
|
||||
VITE_BASE,
|
||||
@@ -74,22 +83,22 @@ async function loadAndConvertEnv(
|
||||
VITE_PWA,
|
||||
VITE_VISUALIZER,
|
||||
} = envConfig;
|
||||
const compress = VITE_COMPRESS || '';
|
||||
const compressTypes = compress
|
||||
|
||||
const compressTypes = (VITE_COMPRESS ?? '')
|
||||
.split(',')
|
||||
.filter((item) => item === 'brotli' || item === 'gzip');
|
||||
|
||||
return {
|
||||
appTitle: VITE_APP_TITLE ?? 'Vben Admin',
|
||||
base: VITE_BASE || '/',
|
||||
compress: !!compress,
|
||||
compressTypes: compressTypes as ('brotli' | 'gzip')[],
|
||||
devtools: VITE_DEVTOOLS === 'true',
|
||||
injectAppLoading: VITE_INJECT_APP_LOADING === 'true',
|
||||
nitroMock: VITE_NITRO_MOCK === 'true',
|
||||
port: Number(VITE_PORT) || 5173,
|
||||
pwa: VITE_PWA === 'true',
|
||||
visualizer: VITE_VISUALIZER === 'true',
|
||||
appTitle: getString(VITE_APP_TITLE, 'Vben Admin'),
|
||||
base: getString(VITE_BASE, '/'),
|
||||
compress: compressTypes.length > 0,
|
||||
compressTypes,
|
||||
devtools: getBoolean(VITE_DEVTOOLS),
|
||||
injectAppLoading: getBoolean(VITE_INJECT_APP_LOADING),
|
||||
nitroMock: getBoolean(VITE_NITRO_MOCK),
|
||||
port: getNumber(VITE_PORT, 5173),
|
||||
pwa: getBoolean(VITE_PWA),
|
||||
visualizer: getBoolean(VITE_VISUALIZER),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user