TenantAtlas/apps/website/process-html.mjs

24 lines
598 B
JavaScript

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 = './dist';
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);
})
);