-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
99 lines (87 loc) · 2.35 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict';
//
//
//
const directoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output');
const htmlmin = require('html-minifier');
const isProduction = process.env.NODE_ENV === 'product' ? true: false;
//
//
//
module.exports = function (eleventyConfig) {
//
// eleventy-plugin-directory-output
//
eleventyConfig.addPlugin(directoryOutputPlugin, {
columns: {
filesize: true,
benchmark: true,
},
warningFileSize: 400 * 1000,
});
//
// 11ty Quiet Mode
//
eleventyConfig.setQuietMode(true);
//
// 11ty Passthrough Copy
//
eleventyConfig.addPassthroughCopy({ './source/static/**/*': './' });
//
// 11ty Nunjucks Environment Options
//
eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true,
autoescape: false,
});
//
// 11ty Watch Target and tWatch Throttle Wait Time
//
eleventyConfig.addWatchTarget('./source/assets/styles/');
eleventyConfig.addWatchTarget('./source/assets/scripts/');
eleventyConfig.setWatchThrottleWaitTime(1000);
//
if (isProduction) {
//
// html-minifier
//
eleventyConfig.addTransform('htmlmin', function(content) {
if (this.page.outputPath && this.page.outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
});
return minified;
}
return content;
});
} else {
//
// eleventy-dev-server, included with 11ty's installation
//
eleventyConfig.setServerOptions({
liveReload: true,
domDiff: true,
port: 8080,
watch: [],
showAllHosts: false,
https: {},
encoding: 'utf-8',
showVersion: false,
});
}
//
return {
markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: './source',
layouts: './_includes',
output: isProduction ? './_product' : './_develop'
}
};
};