mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
perf: optimize for some details and comments (#4030)
* perf: optimize for some details and comments * fix: test case * chore: update ci
This commit is contained in:
@@ -47,7 +47,6 @@ const userConfig = {
|
||||
defaultScope: scopeComplete,
|
||||
// English
|
||||
typesAppend: [
|
||||
{ name: 'wip: work in process', value: 'wip' },
|
||||
{ name: 'workflow: workflow improvements', value: 'workflow' },
|
||||
{ name: 'types: type definition file changes', value: 'types' },
|
||||
],
|
||||
@@ -122,7 +121,7 @@ const userConfig = {
|
||||
'header-max-length': [2, 'always', 108],
|
||||
|
||||
'scope-enum': [0],
|
||||
'subject-case': [0],
|
||||
'subject-case': [2, 'always', 'lower-case'],
|
||||
'subject-empty': [2, 'never'],
|
||||
'type-empty': [2, 'never'],
|
||||
/**
|
||||
|
@@ -15,8 +15,8 @@ import { getCommonConfig } from './common';
|
||||
|
||||
function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
return defineConfig(async (config) => {
|
||||
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
|
||||
const options = await userConfigPromise?.(config);
|
||||
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
|
||||
const { command, mode } = config;
|
||||
const { application = {}, vite = {} } = options || {};
|
||||
const root = process.cwd();
|
||||
@@ -78,16 +78,16 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
|
||||
port,
|
||||
warmup: {
|
||||
// 预热文件
|
||||
clientFiles: ['./index.html', './src/{views,layouts}/*'],
|
||||
clientFiles: ['./index.html', './src/{views,layouts,router,store}/*'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mergedConfig = mergeConfig(
|
||||
const mergedCommonConfig = mergeConfig(
|
||||
await getCommonConfig(),
|
||||
applicationConfig,
|
||||
);
|
||||
return mergeConfig(mergedConfig, vite);
|
||||
return mergeConfig(mergedCommonConfig, vite);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -13,8 +13,8 @@ function defineLibraryConfig(userConfigPromise?: DefineLibraryOptions) {
|
||||
return defineConfig(async (config: ConfigEnv) => {
|
||||
const options = await userConfigPromise?.(config);
|
||||
const { command, mode } = config;
|
||||
const root = process.cwd();
|
||||
const { library = {}, vite = {} } = options || {};
|
||||
const root = process.cwd();
|
||||
const isBuild = command === 'build';
|
||||
|
||||
const plugins = await loadLibraryPlugins({
|
||||
@@ -52,8 +52,8 @@ function defineLibraryConfig(userConfigPromise?: DefineLibraryOptions) {
|
||||
plugins,
|
||||
};
|
||||
const commonConfig = await getCommonConfig();
|
||||
const mergedConfig = mergeConfig(commonConfig, packageConfig);
|
||||
return mergeConfig(mergedConfig, vite);
|
||||
const mergedConmonConfig = mergeConfig(commonConfig, packageConfig);
|
||||
return mergeConfig(mergedConmonConfig, vite);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -28,12 +28,12 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
|
||||
const defaultImportmapOptions: ImportmapPluginOptions = {
|
||||
// 通过 Importmap CDN 方式引入,
|
||||
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
|
||||
defaultProvider: 'jspm.io',
|
||||
defaultProvider: 'esm.sh',
|
||||
importmap: [
|
||||
{ name: 'vue' },
|
||||
{ name: 'pinia' },
|
||||
{ name: 'vue-router' },
|
||||
{ name: 'vue-i18n' },
|
||||
// { name: 'vue-i18n' },
|
||||
{ name: 'dayjs' },
|
||||
{ name: 'vue-demi' },
|
||||
],
|
||||
|
@@ -1,3 +1,3 @@
|
||||
# inject-app-loading
|
||||
|
||||
用于在应用加载时显示加载动画的插件。可自行选择加载动画的样式。
|
||||
用于在应用加载时显示加载动画的插件,可自行选择加载动画的样式。
|
||||
|
@@ -25,7 +25,7 @@
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
transition: all 0.6s ease-out;
|
||||
transition: all 1s ease-out;
|
||||
}
|
||||
|
||||
.dark .loading {
|
||||
|
@@ -52,19 +52,15 @@ async function viteInjectAppLoadingPlugin(
|
||||
* 用于获取loading的html模板
|
||||
*/
|
||||
async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const defaultLoadingPath = join(__dirname, './default-loading.html');
|
||||
// 支持在app内自定义loading模板,模版参考default-loading.html即可
|
||||
const appLoadingPath = join(process.cwd(), loadingTemplate);
|
||||
let loadingPath = defaultLoadingPath;
|
||||
let appLoadingPath = join(process.cwd(), loadingTemplate);
|
||||
|
||||
if (fs.existsSync(appLoadingPath)) {
|
||||
loadingPath = appLoadingPath;
|
||||
return;
|
||||
if (!fs.existsSync(appLoadingPath)) {
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
appLoadingPath = join(__dirname, './default-loading.html');
|
||||
}
|
||||
|
||||
const htmlRaw = await fsp.readFile(loadingPath, 'utf8');
|
||||
return htmlRaw;
|
||||
return await fsp.readFile(appLoadingPath, 'utf8');
|
||||
}
|
||||
|
||||
export { viteInjectAppLoadingPlugin };
|
||||
|
@@ -74,13 +74,13 @@ interface CommonPluginOptions {
|
||||
}
|
||||
|
||||
interface ApplicationPluginOptions extends CommonPluginOptions {
|
||||
/** 开启 gzip 压缩 */
|
||||
/** 开启 gzip|brotli 压缩 */
|
||||
compress?: boolean;
|
||||
/** 压缩类型 */
|
||||
compressTypes?: ('brotli' | 'gzip')[];
|
||||
/** 在构建的时候抽离配置文件 */
|
||||
extraAppConfig?: boolean;
|
||||
/** html 插件配置 */
|
||||
/** 是否开启html插件 */
|
||||
html?: boolean;
|
||||
/** 是否开启i18n */
|
||||
i18n?: boolean;
|
||||
@@ -98,7 +98,7 @@ interface ApplicationPluginOptions extends CommonPluginOptions {
|
||||
nitroMock?: boolean;
|
||||
/** nitro mock 插件配置 */
|
||||
nitroMockOptions?: NitroMockPluginOptions;
|
||||
/** dev是否开启mock服务 */
|
||||
/** 开启控制台自定义打印 */
|
||||
print?: boolean;
|
||||
/** 打印插件配置 */
|
||||
printInfoMap?: PrintPluginOptions['infoMap'];
|
||||
|
Reference in New Issue
Block a user