|
1 | 1 | import fs from 'node:fs/promises' |
2 | | -import { htmlMinifier } from '@node-minify/html-minifier' |
3 | 2 | import { ensureDir } from '@purestack/ts-util-node' |
| 3 | +import { minify } from 'html-minifier-next' |
4 | 4 |
|
5 | 5 | export async function readSource(absPath: string) { |
6 | 6 | return fs.readFile(absPath, 'utf-8') |
@@ -30,16 +30,20 @@ export async function prepareOutDir( |
30 | 30 | } |
31 | 31 |
|
32 | 32 | async function minifyHtml(input: string): Promise<string> { |
33 | | - const result = await htmlMinifier({ |
34 | | - content: input, |
35 | | - settings: { |
36 | | - compressor: async () => ({ code: '' }), |
37 | | - options: { |
38 | | - collapseInlineTagWhitespace: false, |
39 | | - removeOptionalTags: false, |
40 | | - conservativeCollapse: true, |
41 | | - }, |
42 | | - }, |
| 33 | + return minify(input, { |
| 34 | + collapseBooleanAttributes: true, |
| 35 | + collapseInlineTagWhitespace: false, |
| 36 | + collapseWhitespace: true, |
| 37 | + conservativeCollapse: true, |
| 38 | + minifyCSS: true, |
| 39 | + minifyJS: true, |
| 40 | + removeAttributeQuotes: true, |
| 41 | + removeComments: true, |
| 42 | + removeEmptyAttributes: true, |
| 43 | + removeOptionalTags: false, |
| 44 | + removeRedundantAttributes: true, |
| 45 | + removeScriptTypeAttributes: true, |
| 46 | + removeStyleLinkTypeAttributes: true, |
| 47 | + useShortDoctype: true, |
43 | 48 | }) |
44 | | - return result.code |
45 | 49 | } |
0 commit comments