-
Notifications
You must be signed in to change notification settings - Fork 12
/
eleventy.config.ts
129 lines (120 loc) · 3.08 KB
/
eleventy.config.ts
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// @ts-ignore
import EleventyVitePlugin from "@11ty/eleventy-plugin-vite";
// @ts-ignore
import pluginRss from "@11ty/eleventy-plugin-rss";
import { registerIncludes } from "./_includes/config";
import commandLineArgs from "command-line-args";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import { absolutePaths } from "./src/plugins/absolutePaths";
import { metaOpenGraphImagePlugin } from "./src/plugins/metaOpenGraphImagePlugin";
import purgeCss from "@fullhuman/postcss-purgecss";
const options = commandLineArgs([
{ name: "config", type: String },
{ name: "incremental", type: Boolean, defaultOption: false },
{ name: "pathprefix", type: String, defaultValue: "/" },
{ name: "serve", type: Boolean, defaultOption: false },
{ name: "watch", type: Boolean, defaultOption: false },
]);
module.exports = function (eleventyConfig: any) {
// Stop logging every file that gets written
eleventyConfig.setQuietMode(true);
eleventyConfig.addPlugin(EleventyVitePlugin, {
viteOptions: {
clearScreen: true,
appType: "mpa",
css: {
postcss: {
plugins: [
purgeCss({
content: [
// for development
"./_site/**/*.html",
// for production builds
"./.11ty-vite/**/*.html",
],
safelist: {
deep: [
/plyr.*/,
/is-active/,
/fa-robot/,
/has-background-info-light/,
/tag/,
/is-warning/,
/is-pulled-right/,
/is-fullwidth/,
/is-block/,
/has-glow.*/,
/has-gradient.*/,
],
},
}),
],
},
},
plugins: [
ViteImageOptimizer({
exclude: /\.gif$/i,
ansiColors: false,
cache: true,
cacheLocation: ".assets-cache",
}),
absolutePaths({
prefix: options.pathprefix,
}),
metaOpenGraphImagePlugin(),
],
base: options.pathprefix,
server: {
mode: "development",
middlewareMode: true,
watch: {
ignored: ["_site/**"],
},
},
build: {
mode: "production",
rollupOptions: {
output: {
assetFileNames: (info: any) => {
if (
info.name.includes("rss.xml") ||
info.name.includes("lunr.json")
) {
return "[name][extname]";
} else {
return "assets/[name]-[hash][extname]";
}
},
},
},
},
},
});
// These are all relative to the input directory at the end
eleventyConfig.addPassthroughCopy(
"./!(_site)**/*.{gif,jpg,png,svg,jpeg,webm,webp}",
{ overwrite: true }
);
eleventyConfig.addPassthroughCopy(
{ "../../public/assets": "assets" },
{ overwrite: true }
);
eleventyConfig.addPassthroughCopy(
{ "../../public/obsoletes.json": "obsoletes.json" },
{ overwrite: true }
);
eleventyConfig.ignores.add("**/demos/**");
registerIncludes({ eleventyConfig }, process.cwd())
.then((_) => {})
.catch((e) => console.log(e));
eleventyConfig.addGlobalData("commandLineArgs", options);
eleventyConfig.addPlugin(pluginRss);
return {
dir: {
input: "./site",
includes: "../_includes",
layouts: "../_includes",
output: "./_site",
},
};
};