/
.eleventy.js
34 lines (30 loc) · 852 Bytes
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const htmlmin = require("html-minifier");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/static");
if (process.env.ELEVENTY_ENV === 'production') {
// Minify HTML (including inlined CSS)
eleventyConfig.addTransform("compressHTML", function(content, outputPath) {
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true
});
return minified;
}
return content;
});
}
return {
dir: {
input: "src/",
output: "dist",
includes: "_includes",
layouts: "_layouts"
},
templateFormats: ["html", "md", "njk"],
htmlTemplateEngine: "njk",
passthroughFileCopy: true
};
};