-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
47 lines (35 loc) · 1.2 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
require('dotenv').config();
const cacheBuster = require('@mightyplow/eleventy-plugin-cache-buster');
module.exports = function (eleventyConfig) {
eleventyConfig.setServerOptions({
showAllHosts: true,
});
eleventyConfig.on('beforeBuild', () => {
const fs = require('fs');
const content = fs.readFileSync('content/_data/rounds.mjs', 'utf8');
const modified = content.replace(/^export default[\s\S]*$/m, '');
if (!fs.existsSync('_site/assets')) {
fs.mkdirSync('_site/assets', { recursive: true });
}
fs.writeFileSync('_site/assets/rounds.js', modified);
});
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
if (process.env.ENVIRONMENT === "development") {
eleventyConfig.addPassthroughCopy({ public: '/' });
} else {
const cacheBusterOptions = {};
eleventyConfig.addPlugin(cacheBuster(cacheBusterOptions));
}
eleventyConfig.addShortcode("assertIsNotEmpty", function (value, message) {
if (value === undefined || value === null || value === "") {
throw new Error(`Value is empty: ${message}`);
}
});
eleventyConfig.ignores.add("README.md");
return {
dir: {
input: 'content'
},
pathPrefix: "/",
};
};