mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-05-09 03:51:25 +08:00
Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into dev
This commit is contained in:
@@ -55,7 +55,6 @@
|
||||
"unplugin-dts": "catalog:",
|
||||
"vite": "catalog:",
|
||||
"vite-plugin-compression": "catalog:",
|
||||
"vite-plugin-html": "catalog:",
|
||||
"vite-plugin-lazy-import": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
35
internal/vite-config/src/plugins/html.ts
Normal file
35
internal/vite-config/src/plugins/html.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Options as HtmlMinifierOptions } from 'html-minifier-terser';
|
||||
import type { PluginOption } from 'vite';
|
||||
|
||||
import { minify } from 'html-minifier-terser';
|
||||
|
||||
const HTML_MINIFY_OPTIONS = {
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
removeComments: true,
|
||||
removeRedundantAttributes: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
useShortDoctype: true,
|
||||
} as const;
|
||||
|
||||
function viteHtmlPlugin(options: HtmlMinifierOptions = {}): PluginOption {
|
||||
return {
|
||||
name: 'vben-native-html',
|
||||
transformIndexHtml: {
|
||||
order: 'post',
|
||||
async handler(html, ctx) {
|
||||
if (!ctx.bundle) {
|
||||
return html;
|
||||
}
|
||||
return await minify(html, {
|
||||
...HTML_MINIFY_OPTIONS,
|
||||
...options,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export { viteHtmlPlugin };
|
||||
@@ -14,12 +14,12 @@ import viteVueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import { visualizer as viteVisualizerPlugin } from 'rollup-plugin-visualizer';
|
||||
import viteDtsPlugin from 'unplugin-dts/vite';
|
||||
import viteCompressPlugin from 'vite-plugin-compression';
|
||||
import { createHtmlPlugin as viteHtmlPlugin } from 'vite-plugin-html';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import viteVueDevTools from 'vite-plugin-vue-devtools';
|
||||
|
||||
import { viteArchiverPlugin } from './archiver';
|
||||
import { viteExtraAppConfigPlugin } from './extra-app-config';
|
||||
import { viteHtmlPlugin } from './html';
|
||||
import { viteImportMapPlugin } from './importmap';
|
||||
import { viteInjectAppLoadingPlugin } from './inject-app-loading';
|
||||
import { viteMetadataPlugin } from './inject-metadata';
|
||||
@@ -199,7 +199,7 @@ async function loadApplicationPlugins(
|
||||
},
|
||||
{
|
||||
condition: !!html,
|
||||
plugins: () => [viteHtmlPlugin({ minify: true })],
|
||||
plugins: () => [viteHtmlPlugin(typeof html === 'object' ? html : {})],
|
||||
},
|
||||
{
|
||||
condition: isBuild && importmap,
|
||||
|
||||
@@ -103,5 +103,5 @@
|
||||
</style>
|
||||
<div class="loading" id="__app-loading__">
|
||||
<span class="dot"><i></i><i></i><i></i><i></i></span>
|
||||
<div class="title"><%= VITE_APP_TITLE %></div>
|
||||
<div class="title">%VITE_APP_TITLE%</div>
|
||||
</div>
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
|
||||
.loading.hidden {
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: all 0.8s ease-out;
|
||||
}
|
||||
@@ -109,5 +109,5 @@
|
||||
</style>
|
||||
<div class="loading" id="__app-loading__">
|
||||
<div class="loader"></div>
|
||||
<div class="title"><%= VITE_APP_TITLE %></div>
|
||||
<div class="title">%VITE_APP_TITLE%</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Options as HtmlMinifierOptions } from 'html-minifier-terser';
|
||||
import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
|
||||
import type { PluginOptions } from 'unplugin-dts';
|
||||
import type {
|
||||
@@ -94,6 +95,12 @@ interface ArchiverPluginOptions {
|
||||
outputDir?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 插件配置
|
||||
* @description 用于配置基于 transformIndexHtml 的 HTML 压缩行为
|
||||
*/
|
||||
type HtmlPluginOptions = HtmlMinifierOptions;
|
||||
|
||||
/**
|
||||
* ImportMap 插件配置
|
||||
* @description 用于配置模块的 CDN 导入
|
||||
@@ -217,7 +224,7 @@ interface ApplicationPluginOptions extends CommonPluginOptions {
|
||||
* 是否开启 HTML 插件
|
||||
* @default true
|
||||
*/
|
||||
html?: boolean;
|
||||
html?: boolean | HtmlPluginOptions;
|
||||
/**
|
||||
* 是否开启国际化
|
||||
* @default false
|
||||
@@ -342,6 +349,7 @@ export type {
|
||||
DefineApplicationOptions,
|
||||
DefineConfig,
|
||||
DefineLibraryOptions,
|
||||
HtmlPluginOptions,
|
||||
IImportMap,
|
||||
ImportmapPluginOptions,
|
||||
LibraryPluginOptions,
|
||||
|
||||
Reference in New Issue
Block a user