feat(html): minify static and dynamic html output
This commit is contained in:
parent
b6d5933433
commit
f4b6436460
18 changed files with 305 additions and 7 deletions
17
config/plugins/html-config.js
Normal file
17
config/plugins/html-config.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import htmlmin from 'html-minifier-terser';
|
||||
|
||||
export const htmlConfig = (eleventyConfig) => {
|
||||
eleventyConfig.addTransform('html-minify', (content, path) => {
|
||||
if (path && (path.endsWith('.html') || path.endsWith('.php'))) {
|
||||
return htmlmin.minify(content, {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseWhitespace: true,
|
||||
decodeEntities: true,
|
||||
includeAutoGeneratedTags: false,
|
||||
removeComments: true
|
||||
});
|
||||
}
|
||||
|
||||
return content;
|
||||
});
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { cssConfig } from "./css-config.js";
|
||||
import { htmlConfig } from "./html-config.js";
|
||||
import { markdownLib } from "./markdown.js";
|
||||
|
||||
export default { cssConfig, markdownLib };
|
||||
export default { cssConfig, htmlConfig, markdownLib };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue