-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
57 lines (50 loc) · 1.6 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
45
46
47
48
49
50
51
52
53
54
55
56
57
const filters = require("./utils/filters.js")
const esbuild = require("esbuild");
const { sassPlugin } = require("esbuild-sass-plugin");
const htmlmin = require("html-minifier-terser");
module.exports = function (eleventyConfig) {
eleventyConfig.addGlobalData("generated", () => {
let now = new Date();
return new Intl.DateTimeFormat(
"en-GB", { dateStyle: "medium", timeStyle: "long", timeZone: "UTC" }
).format(now);
});
// Add Filters
Object.keys(filters).forEach((filterName) => {
eleventyConfig.addFilter(filterName, filters[filterName])
})
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
if (outputPath && outputPath.endsWith(".html") && process.env.NODE_ENV === "production") {
return htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
}
return content;
});
eleventyConfig.on("afterBuild", () => {
return esbuild.build({
entryPoints: ["_site/_esbuild/app.scss", "_site/_esbuild/app.js"],
outdir: "_site/assets",
bundle: true,
legalComments: "linked",
minify: process.env.NODE_ENV === "production",
sourcemap: process.env.NODE_ENV !== "production",
plugins: [sassPlugin()]
});
});
eleventyConfig.addWatchTarget("./src/sass/");
eleventyConfig.addWatchTarget("./src/js/");
return {
dir: {
input: "src/",
output: "_site",
includes: "_includes",
layouts: "_layouts"
},
templateFormats: ["html", "md", "njk"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk"
};
};