diff --git a/.eleventy.js b/.eleventy.js index 38e390e..0762fce 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,10 +1,22 @@ const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight') const markdownIt = require('markdown-it') const markdownItAnchor = require('markdown-it-anchor') +const htmlmin = require("html-minifier") module.exports = function(eleventyConfig) { // Plugins eleventyConfig.addPlugin(syntaxHighlight) + eleventyConfig.addTransform("htmlmin", (content, outputPath) => { + if (outputPath.endsWith(".html")) { + return htmlmin.minify(content, { + collapseWhitespace: true, + removeComments: true, + useShortDoctype: true, + }); + } + + return content; + }); // To enable merging of tags eleventyConfig.setDataDeepMerge(true) diff --git a/package.json b/package.json index 67a80ec..a5dbd83 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "devDependencies": { "@11ty/eleventy": ">=0.11.1", "@11ty/eleventy-plugin-syntaxhighlight": ">=3.0.4", - "eslint": ">=7.12.1" + "eslint": ">=7.12.1", + "html-minifier": ">=3.5.21" }, "dependencies": { "@tailwindcss/typography": "^0.4.0",