-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
31 lines (27 loc) · 908 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
const htmlmin = require("html-minifier-terser");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/js");
eleventyConfig.addPassthroughCopy("src/robots.txt");
eleventyConfig.addPassthroughCopy("src/favicon.svg");
// Add year shortcode
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
if (process.env.NODE_ENV === "production" && outputPath && outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
removeComments: true,
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
useShortDoctype: true,
});
return minified;
}
return content;
});
return {
dir: {
input: "src",
output: "_site"
}
};
};