mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
chore: minify html
This commit is contained in:
@@ -3,9 +3,10 @@ import viteConfig, { htmlConfig } from '../../vite.config';
|
||||
import { getCwdPath, successConsole, errorConsole } from '../utils';
|
||||
import { GLOB_CONFIG_FILE_NAME } from '../constant';
|
||||
import { hmScript } from './hm';
|
||||
import HtmlMinifier from 'html-minifier';
|
||||
const pkg = require('../../package.json');
|
||||
|
||||
const { title, addHm, cdnConf, useCdn } = htmlConfig;
|
||||
const { title, addHm, cdnConf, useCdn, minify } = htmlConfig;
|
||||
|
||||
function injectTitle(html: string, htmlTitle: string) {
|
||||
if (/<\/title>/.test(html)) {
|
||||
@@ -89,6 +90,10 @@ export async function runUpdateHtml() {
|
||||
processedHtml = injectCdnCss(processedHtml);
|
||||
processedHtml = injectCdnjs(processedHtml);
|
||||
}
|
||||
if (minify) {
|
||||
const { enable, ...miniOpt } = minify;
|
||||
processedHtml = HtmlMinifier.minify(processedHtml, miniOpt);
|
||||
}
|
||||
|
||||
writeFileSync(indexPath, processedHtml);
|
||||
successConsole('Update Html Successfully!');
|
||||
|
Reference in New Issue
Block a user