-
Notifications
You must be signed in to change notification settings - Fork 8
/
.eleventy.js
39 lines (32 loc) · 851 Bytes
/
.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
const fs = require("fs");
const htmlmin = require("html-minifier-terser");
module.exports = function(eleventyConfig) {
if (process.env.ELEVENTY_PRODUCTION) {
eleventyConfig.addTransform("htmlmin", htmlminTransform);
}
// Passthrough
eleventyConfig.addPassthroughCopy({ "src/static": "." });
// Watch targets
eleventyConfig.addWatchTarget("./src/styles/");
var pathPrefix = "";
if (process.env.GITHUB_REPOSITORY) {
pathPrefix = process.env.GITHUB_REPOSITORY.split('/')[1];
}
return {
dir: {
input: "src"
},
pathPrefix
}
};
function htmlminTransform(content, outputPath) {
if( outputPath.endsWith(".html") ) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
}