-
-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathprocess-html.mjs
More file actions
23 lines (20 loc) · 615 Bytes
/
process-html.mjs
File metadata and controls
23 lines (20 loc) · 615 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import fs from 'node:fs/promises';
import { globby } from 'globby';
import { minify } from 'html-minifier-terser';
// Get all HTML files from the output directory
const path = './.vercel/output/static';
const files = await globby(`${path}/**/*.html`);
await Promise.all(
files.map(async file => {
console.log('Processing file:', file);
let html = await fs.readFile(file, 'utf-8');
// Minify the HTML
html = await minify(html, {
removeComments: true,
preserveLineBreaks: true,
collapseWhitespace: true,
minifyJS: true,
});
await fs.writeFile(file, html);
})
);