achat-maison-albi-fr/process-html.mjs
Emil Gulamov 30a71a2e9c Update dependencies to newer versions
Updated several key dependencies in package.json and package-lock.json to their newer versions. Also replaced 'html-minifier' with 'html-minifier-terser'. The updates include minor and patch upgrades.
2024-05-06 23:06:52 +04:00

23 lines
No EOL
612 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 = './.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)
})
)