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.
23 lines
No EOL
612 B
JavaScript
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)
|
|
})
|
|
) |