-
Notifications
You must be signed in to change notification settings - Fork 4
/
.eleventy.js
44 lines (38 loc) · 1.28 KB
/
.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
44
const htmlmin = require("html-minifier");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function (eleventyConfig) {
// Layout aliases for convenience
eleventyConfig.addLayoutAlias("base", "layouts/base.njk");
eleventyConfig.addLayoutAlias("page", "layouts/page.njk");
// Passthrough all images
eleventyConfig.addPassthroughCopy("./src/assets/images/");
eleventyConfig.addPassthroughCopy("./src/sw.js");
eleventyConfig.addPassthroughCopy("./src/*.png");
eleventyConfig.addPassthroughCopy("./src/*.svg");
//eleventyConfig.addPassthroughCopy("./src/assets/css/");
// Plugins
eleventyConfig.addPlugin(eleventyNavigationPlugin);
// Transforms
// minify the html output when running in production
if (process.env.NODE_ENV == "production") {
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
}
return {
dir: {
input: "src",
output: "dist",
},
templateFormats: ["njk", "md", "html"],
htmlTemplateEngine: "njk",
};
};