Skip to content

Commit f0441d5

Browse files
committedJul 29, 2024
修复bug
1 parent bbf699b commit f0441d5

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed
 

‎docs/01.热.我.md

-3
This file was deleted.

‎src/index.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import { exec } from "child_process";
1010
import mime from "mime";
1111
import workerpool from "workerpool";
1212
import os from "os";
13-
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
import process from "process";
14+
import { minify } from "html-minifier";
15+
16+
const __filename = fileURLToPath(import.meta.url);
17+
const __dirname = dirname(__filename);
1418

1519
export const distDir = join(__dirname, "../dist");
1620
export const docsDir = join(__dirname, "../docs");
@@ -30,6 +34,9 @@ console.timeEnd("HTML 生成");
3034
console.time("gzip 压缩");
3135
await compression();
3236
console.timeEnd("gzip 压缩");
37+
if (process.argv[1] === __filename) {
38+
process.exit(0);
39+
}
3340

3441
export async function build() {
3542
await clean();
@@ -38,6 +45,20 @@ export async function build() {
3845
genContent(),
3946
]);
4047
template = template.replaceAll("{{content}}", content);
48+
template = minify(template, {
49+
collapseWhitespace: true,
50+
conservativeCollapse: true,
51+
minifyCSS: true,
52+
minifyJS: true,
53+
minifyURLs: true,
54+
removeComments: true,
55+
removeRedundantAttributes: true,
56+
removeScriptTypeAttributes: true,
57+
removeStyleLinkTypeAttributes: true,
58+
sortAttributes: true,
59+
sortClassName: true,
60+
useShortDoctype: true,
61+
});
4162
await genDir(docsDir, publicDir, themeDir);
4263
}
4364

0 commit comments

Comments
 (0)