-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
37 lines (33 loc) · 989 Bytes
/
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
import { minify } from "html-minifier-terser";
/**
* @see https://www.11ty.dev/docs/config/
* @param {import("@11ty/eleventy").UserConfig} eleventyConfig
*/
export default function (eleventyConfig) {
// Copy the contents of the `public` folder to the output folder
eleventyConfig.addPassthroughCopy({ "./public/": "/" });
// Add a transform to minify HTML and CSS output
// https://www.11ty.dev/docs/transforms/#minify-html-output
eleventyConfig.addTransform("htmlmin", function (content) {
if ((this.page.outputPath || "").endsWith(".html")) {
return minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
minifyCSS: true,
removeAttributeQuotes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
sortAttributes: true,
sortClassName: true,
});
}
// If not an HTML output, return content as-is
return content;
});
return {
dir: {
input: "content",
includes: "../_includes",
},
};
}