Skip to content

Commit

Permalink
Merge pull request #2 from marknorrapscm/master
Browse files Browse the repository at this point in the history
Add HTML minification and favicon support
  • Loading branch information
surjithctly authored Dec 23, 2020
2 parents 3521f93 + 6e5096a commit f6c90d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const yaml = require("js-yaml");
const { DateTime } = require("luxon");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const htmlmin = require("html-minifier");

module.exports = function (eleventyConfig) {
// Disable automatic use of your .gitignore
Expand Down Expand Up @@ -40,6 +41,24 @@ module.exports = function (eleventyConfig) {
// Copy Image Folder to /_site
eleventyConfig.addPassthroughCopy("./src/static/img");

// Copy favicon to route of /_site
eleventyConfig.addPassthroughCopy("./src/favicon.ico");

// Minify HTML
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
// Eleventy 1.0+: use this.inputPath and this.outputPath instead
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}

return content;
});

// Let Eleventy transform HTML files as nunjucks
// So that we can use .html instead of .njk
return {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@tailwindcss/typography": "^0.2.0",
"alpinejs": "^2.6.0",
"cross-env": "^7.0.2",
"html-minifier": "^4.0.0",
"js-yaml": "^3.14.0",
"luxon": "^1.25.0",
"npm-run-all": "^4.1.5",
Expand All @@ -20,4 +21,4 @@
"prismjs": "^1.21.0",
"tailwindcss": "^1.7.2"
}
}
}
Binary file added src/favicon.ico
Binary file not shown.

0 comments on commit f6c90d4

Please sign in to comment.