-
Notifications
You must be signed in to change notification settings - Fork 66
/
.eleventy.js
46 lines (41 loc) · 1.27 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
const htmlmin = require('html-minifier');
module.exports = function (config) {
config.addPassthroughCopy('src/assets');
config.addPassthroughCopy('src/favicon.ico');
config.addPassthroughCopy('src/screenshots');
config.addPassthroughCopy('src/fonts-for-ui');
config.addCollection('fonts', function (collection) {
let fonts = collection
.getFilteredByGlob('src/fonts/*.md')
.sort((a, b) => (b.data.title < a.data.title ? 1 : -1));
return fonts;
});
// is production build (netlify) :: minify html
if (process.env.PROD === 'true') {
// pulled from Eleventy docs
// https://www.11ty.dev/docs/config/#transforms-example-minify-html-output
config.addTransform('htmlmin', function (content, outputPath) {
if (outputPath && outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
});
}
return {
dir: {
input: 'src',
output: 'dist',
includes: '_includes',
data: '_data'
},
passthroughFileCopy: true,
templateFormats: ['njk', 'md'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk'
};
};