feat: add html minify
This commit is contained in:
parent
7b1f6d7eb6
commit
1d4a8416f3
4 changed files with 398 additions and 0 deletions
20
config/transforms/html-config.js
Normal file
20
config/transforms/html-config.js
Normal 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;
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue