-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
52 lines (45 loc) · 1.29 KB
/
eleventy.config.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
import htmlmin from "html-minifier-terser";
import CleanCSS from "clean-css";
import favicons from "eleventy-plugin-gen-favicons";
import jsonmin from "jsonminify";
export default async function(eleventyConfig) {
eleventyConfig.addPlugin(favicons, {})
if (process.env.ELEVENTY_RUN_MODE === "build") {
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (outputPath && outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeComments: true,
sortAttributes: true
});
return minified;
};
return content;
});
eleventyConfig.addTransform("cssmin", function (code, outputPath) {
if (outputPath && outputPath.endsWith(".css")) {
return new CleanCSS({}).minify(code).styles;
};
return code;
});
eleventyConfig.addTransform("jsonmin", function (json, outputPath) {
if (outputPath && outputPath.endsWith(".webmanifest")) {
return new jsonmin(json);
};
return json;
});
};
eleventyConfig.addPassthroughCopy("src/_headers");
eleventyConfig.addPassthroughCopy("src/robots.txt");
eleventyConfig.setServerOptions({
showAllHosts: true
});
return {
htmlTemplateEngine: "njk",
mdTemplateEngine: "njk",
dir: {
input: "src"
}
};
};