-
Notifications
You must be signed in to change notification settings - Fork 4
/
.eleventy.js
57 lines (52 loc) · 1.74 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 htmlmin = require("html-minifier");
const esbuild = require("esbuild");
const CleanCSS = require("clean-css");
const { EleventyEdgePlugin } = require("@11ty/eleventy");
module.exports = function (eleventyConfig) {
eleventyConfig.on("afterBuild", () => {
return esbuild.build({
entryPoints: {
transliterate: "src/assets/js/transliterate.js",
remove: "src/assets/js/remove.js",
structure: "src/assets/js/structure.js",
friconix: "src/assets/js/friconix.js",
about: "src/assets/js/about.js",
},
outdir: "dist/assets",
format: "iife",
bundle: true,
minify: process.env.NODE_ENV && process.env.NODE_ENV == "production",
});
});
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (process.env.ELEVENTY_PRODUCTION && outputPath && outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
eleventyConfig.addPlugin(EleventyEdgePlugin);
// adds a copy to dist
eleventyConfig.addPassthroughCopy("src/assets/img/*");
// triggers a rebuild when anything in here changes
eleventyConfig.addWatchTarget("src/assets/css/main.css");
eleventyConfig.addWatchTarget("src/assets/js/");
eleventyConfig.addFilter("cssmin", function (code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
return {
dir: {
input: "src",
output: "dist",
data: "_data",
layouts: "_layouts",
includes: "_includes",
},
templateFormats: ["njk", "md", "html", "11ty.js"],
};
};