feat: add html minify

This commit is contained in:
Devin Haska 2024-02-27 10:33:45 -08:00
parent 7b1f6d7eb6
commit 1d4a8416f3
4 changed files with 398 additions and 0 deletions

View file

@ -0,0 +1,20 @@
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,
minifyURLs: true,
removeComments: true,
useShortDoctype: true,
});
}
return content;
});
};