-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
74 lines (66 loc) · 1.99 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
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
import pwa, { type PwaOptions } from "@vite-pwa/astro";
import icon from "astro-icon";
import { defineConfig, envField } from "astro/config";
import { loadEnv } from "vite";
import vercel from "@astrojs/vercel/serverless";
const manifest = (() => {
type ManifestPromise = Promise<PwaOptions["manifest"]>;
try {
return import("./manifest.json").then((r) => r.default) as ManifestPromise;
} catch (error) {
return {} as ManifestPromise;
}
})();
const PWAOptions: PwaOptions = {
registerType: "prompt",
pwaAssets: { disabled: false, config: true, overrideManifestIcons: true },
experimental: { directoryAndTrailingSlashHandler: true },
manifest: await manifest,
devOptions: { enabled: false, suppressWarnings: true, type: "module" },
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
},
};
type Environment = NonNullable<
ReturnType<typeof import("astro/config")["defineConfig"]>["experimental"]
>["env"];
const f = envField;
const environment: Environment = {
validateSecrets: true,
schema: {
PUBLIC_URL: f.string({ context: "client", access: "public", url: true }),
DB_URL: f.string({ context: "server", access: "secret", url: true }),
ASTRO_KEY: f.string({ context: "server", access: "secret" }),
},
};
const mode = process.env.NODE_ENV ?? "production";
const envVars = loadEnv(mode, process.cwd(), "");
// https://astro.build/config
export default defineConfig({
output: "server",
site: envVars.PUBLIC_URL,
experimental: {
globalRoutePriority: true,
contentCollectionCache: true,
serverIslands: true,
contentIntellisense: true,
contentLayer: true,
directRenderScript: true,
env: environment,
},
security: { checkOrigin: true },
integrations: [
icon({
iconDir: "src/assets/icons",
include: { mdi: ["play", "pause"], logos: ["astro-icon"] },
}),
pwa(PWAOptions),
],
adapter: vercel({
imageService: true,
webAnalytics: {
enabled: envVars.NODE_ENV === "production",
},
}),
});