-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eleventy.js
60 lines (46 loc) · 1.78 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
48
49
50
51
52
53
54
55
56
57
58
59
60
const fs = require("fs");
const path = require("path");
const isDev = process.env.APP_ENV === "development";
const manifestPath = path.resolve(__dirname, "dist", "manifest.json");
const manifest = isDev ? {
"main.css": "assets/css/bundle.css",
"main.js": "assets/js/bundle.js",
"assets/favicon.png": "assets/favicon.png",
} : JSON.parse(fs.readFileSync(manifestPath, { encoding: "utf8" }));
module.exports = function (eleventyConfig) {
eleventyConfig.addLayoutAlias("base", "base.njk");
eleventyConfig.addShortcode("bundledCss", function () {
return manifest["main.css"]
? `<link href="${manifest["main.css"]}" rel="stylesheet" />`
: "";
});
eleventyConfig.addShortcode("xtermCss", function () {
return `<link href="assets/css/xterm.css" rel="stylesheet" />`;
});
eleventyConfig.addShortcode("spinCss", function () {
return `<link href="assets/css/spin.css" rel="stylesheet" />`;
});
eleventyConfig.addShortcode("bundledJs", function () {
return manifest["main.js"]
? `<script src="${manifest["main.js"]}"></script>`
: "";
});
eleventyConfig.addShortcode("bundledIco", function () {
return manifest["main.js"]
? `<link rel="icon" href="${manifest["assets/favicon.png"]}" type="image/png" />`
: "";
});
eleventyConfig.addPassthroughCopy({ "src/assets/public": "assets" });
eleventyConfig.addPassthroughCopy({ "node_modules/xterm/css/xterm.css": "assets/css/xterm.css" });
eleventyConfig.addPassthroughCopy({ "node_modules/spin.js/spin.css": "assets/css/spin.css" });
eleventyConfig.setBrowserSyncConfig({ files: ["src/includes/*.njk", "dist/assets/**/*"] });
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data',
},
};
};