This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/config/transforms/html-config.js
2023-12-20 16:08:00 -08:00

19 lines
576 B
JavaScript

const htmlmin = require('html-minifier-terser')
module.exports = (eleventyConfig) => {
eleventyConfig.addTransform('html-minify', (content, path) => {
if (path && path.endsWith('.html')) {
return htmlmin.minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
includeAutoGeneratedTags: false,
minifyCSS: true,
minifyJS: true,
removeComments: true,
processScripts: ['application/ld+json'], // minify JSON-LD scripts
})
}
return content
})
}