-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
45 lines (41 loc) · 1.17 KB
/
astro.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
import { defineConfig } from "astro/config";
import sitemap from "@astrojs/sitemap";
import image from "@astrojs/image";
import mdx from "@astrojs/mdx";
import { fileURLToPath } from "url";
import path from "path";
import { readFileSync } from "fs";
import { Plugin } from "rollup";
// Adapted from https://stackoverflow.com/questions/73847316
const bufferLoader: Plugin = {
name: "buffer-loader",
transform(_, id) {
const [path, query] = id.split("?");
if (query != "buffer") return null;
const data = readFileSync(path);
const hex = data.toString("hex");
return `export default Buffer.from("${hex}", "hex");`;
},
};
// https://astro.build/config
export default defineConfig({
integrations: [
image({ serviceEntryPoint: "@astrojs/image/sharp" }),
mdx(),
sitemap(),
],
vite: {
plugins: [bufferLoader],
ssr: {
external: ["svgo"],
},
resolve: {
alias: {
node_modules: path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"node_modules"
),
},
},
},
});