Skip to content

Commit ab81b8c

Browse files
committed
feat(perf): use @minify-html
1 parent e1494c6 commit ab81b8c

File tree

4 files changed

+92
-13
lines changed

4 files changed

+92
-13
lines changed

package-lock.json

Lines changed: 87 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dependencies": {
4141
"@actions/core": "^1.11.1",
4242
"@clack/prompts": "^0.11.0",
43+
"@minify-html/node": "^0.16.4",
4344
"@node-core/rehype-shiki": "1.0.1-1815fa769361b836fa52cfab9c5bd4991f571c95",
4445
"@orama/orama": "^3.1.7",
4546
"@orama/plugin-data-persistence": "^3.1.7",

src/generators/legacy-html-all/index.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { readFile, writeFile } from 'node:fs/promises';
44
import { join, resolve } from 'node:path';
55

6-
import { minify } from 'html-minifier-terser';
6+
import HTMLMinifier from '@minify-html/node';
77

88
import { getRemarkRehype } from '../../utils/remark.mjs';
99
import dropdowns from '../legacy-html/utils/buildDropdowns.mjs';
@@ -95,9 +95,7 @@ export default {
9595
.replace('__EDIT_ON_GITHUB__', '');
9696

9797
// We minify the html result to reduce the file size and keep it "clean"
98-
const minified = await minify(generatedAllTemplate, {
99-
collapseWhitespace: true,
100-
});
98+
const minified = HTMLMinifier.minify(Buffer.from(generatedAllTemplate), {});
10199

102100
if (output) {
103101
await writeFile(join(output, 'all.html'), minified);

src/generators/legacy-html/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { cp, readFile, rm, writeFile } from 'node:fs/promises';
44
import { join } from 'node:path';
55

6-
import { minify } from 'html-minifier-terser';
6+
import HTMLMinifier from '@minify-html/node';
77

88
import buildContent from './utils/buildContent.mjs';
99
import dropdowns from './utils/buildDropdowns.mjs';
@@ -162,7 +162,7 @@ export default {
162162

163163
if (output) {
164164
// We minify the html result to reduce the file size and keep it "clean"
165-
const minified = await minify(result, { collapseWhitespace: true });
165+
const minified = HTMLMinifier.minify(Buffer.from(result), {});
166166

167167
await writeFile(join(output, `${node.api}.html`), minified);
168168
}

0 commit comments

Comments
 (0)