Minify html
This commit is contained in:
parent
11f88bbd03
commit
d1607c74e3
12
.eleventy.js
12
.eleventy.js
@ -1,10 +1,22 @@
|
|||||||
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
|
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
|
||||||
const markdownIt = require('markdown-it')
|
const markdownIt = require('markdown-it')
|
||||||
const markdownItAnchor = require('markdown-it-anchor')
|
const markdownItAnchor = require('markdown-it-anchor')
|
||||||
|
const htmlmin = require("html-minifier")
|
||||||
|
|
||||||
module.exports = function(eleventyConfig) {
|
module.exports = function(eleventyConfig) {
|
||||||
// Plugins
|
// Plugins
|
||||||
eleventyConfig.addPlugin(syntaxHighlight)
|
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
|
// To enable merging of tags
|
||||||
eleventyConfig.setDataDeepMerge(true)
|
eleventyConfig.setDataDeepMerge(true)
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@11ty/eleventy": ">=0.11.1",
|
"@11ty/eleventy": ">=0.11.1",
|
||||||
"@11ty/eleventy-plugin-syntaxhighlight": ">=3.0.4",
|
"@11ty/eleventy-plugin-syntaxhighlight": ">=3.0.4",
|
||||||
"eslint": ">=7.12.1"
|
"eslint": ">=7.12.1",
|
||||||
|
"html-minifier": ">=3.5.21"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/typography": "^0.4.0",
|
"@tailwindcss/typography": "^0.4.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user