-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
41 lines (35 loc) · 1.16 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
module.exports = function (config) {
// A useful way to reference the context we are runing eleventy in
let env = process.env.ELEVENTY_ENV;
// Layout aliases can make templates more portable
config.addLayoutAlias("default", "layouts/base.njk");
// Add some utility filters
config.addFilter("dateDisplay", require("./src/utils/filters/date.js"));
// minify the html output
config.addTransform("htmlmin", require("./src/utils/minify-html.js"));
// compress and combine js files
config.addFilter("jsmin", function (code) {
const UglifyJS = require("uglify-js");
let minified = UglifyJS.minify(code);
if (minified.error) {
console.log("UglifyJS error: ", minified.error);
return code;
}
return minified.code;
});
// pass some assets right through
config.addPassthroughCopy("./src/site/images");
// make the seed target act like prod
env = env == "seed" ? "prod" : env;
return {
dir: {
input: "src/site",
output: "dist",
data: `_data/${env}`,
},
templateFormats: ["njk", "md", "11ty.js"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
passthroughFileCopy: true,
};
};