refactor(vite-plugins): 重新命名插件文件以优化加载顺序
Some checks failed
CI/CD Pipeline / build-and-deploy (push) Has been cancelled
CI/CD Pipeline / playwright (push) Has been cancelled

This commit is contained in:
严浩
2025-10-23 22:38:16 +08:00
parent 29d3000b50
commit a09b1da78d
14 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import type { PluginOption } from 'vite';
import { minify as minifyHtml } from 'html-minifier-terser';
function IndexHtmlPlugin(): PluginOption {
return {
name: 'index-html-plugin',
apply: 'build',
async transformIndexHtml(html) {
console.time('minifyHtml');
// 压缩 HTML
const minifiedHtml = await minifyHtml(html, {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyCSS: true,
minifyJS: true,
});
console.log();
console.timeEnd('minifyHtml');
return minifiedHtml;
},
};
}
export default [IndexHtmlPlugin()] satisfies PluginOption[];