-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
60 lines (56 loc) · 1.33 KB
/
astro.config.mjs
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
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
// https://docs.astro.build/en/guides/integrations-guide/sitemap/
import sitemap from "@astrojs/sitemap";
import { loadEnv } from "vite";
// load config-specfic env vars
import Compress from "astro-compress";
const env = loadEnv(process.env.NODE_ENV, process.cwd(), "");
const isProd = import.meta.env.PROD;
let fullUrl = env.BASE || "https://purarue.xyz/x";
let port = env.PORT || "4321";
// is probably '/x'
const base = new URL(fullUrl).pathname;
// force localhost if not prod
if (!isProd) {
fullUrl = `http://localhost:${port}${base}`;
}
console.log({
site: fullUrl,
isProd,
});
// https://astro.build/config
export default defineConfig({
site: fullUrl,
prefetch: {
defaultStrategy: "hover",
prefetchAll: true, // on hover, pre fetch site links
},
// this gets exposed as import.meta.env.BASE_URL
base: base,
trailingSlash: "ignore",
integrations: [
mdx(),
sitemap({
filter: (page) => {
if (page.includes("notes/personal")) {
return false;
}
return true;
},
}),
Compress({
CSS: false,
HTML: false,
Image: false,
JavaScript: true,
SVG: false,
}),
],
vite: {
// ignore d.ts files
optimizeDeps: {
exclude: ["*.d.ts"],
},
},
});