-
Notifications
You must be signed in to change notification settings - Fork 10
/
.eleventy.js
43 lines (36 loc) · 923 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
35
36
37
38
39
40
41
42
43
const htmlmin = require('html-minifier');
function eleventyConfig(config) {
// Passthroughs
config.addPassthroughCopy("src/img");
// Layout aliases
config.addLayoutAlias("base", "layouts/base.njk");
// Minify HTML
const isProduction = process.env.ELEVENTY_ENV === "production";
var htmlMinify = function(value, outputPath) {
if (outputPath && outputPath.indexOf('.html') > -1) {
return htmlmin.minify(value, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true
});
}
}
// html min only in production
if (isProduction) {
config.addTransform("htmlmin", htmlMinify);
}
// Configuration
return {
dir: {
input: "src",
output: "dist",
includes: "includes",
data: "data",
},
templateFormats: ["html", "njk", "md", "11ty.js"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
};
};
module.exports = eleventyConfig;