-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
34 lines (30 loc) · 1.07 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
// Imports useful for minifying functionality
const cleancss = require("clean-css");
const htmlmin = require("html-minifier");
module.exports = function (eleventyConfig) {
// The directory to copy while building the eleventy app
eleventyConfig.addPassthroughCopy("src/assets");
// Configuration responsible for minifying html
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
});
// Configuration responsible for minifying css
eleventyConfig.addFilter("cssmin", function (code) {
return new cleancss({}).minify(code).styles;
});
// Configuration responsible for specifying the input and output directories to eleventy build command
return {
dir: {
input: "src",
output: "build"
}
};
};