-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
75 lines (73 loc) · 2.3 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import mdx from '@astrojs/mdx'
import netlify from '@astrojs/netlify'
import react from '@astrojs/react'
import sitemap from '@astrojs/sitemap'
import keystatic from '@keystatic/astro'
import tailwindcss from '@tailwindcss/vite'
import { defineConfig, envField } from 'astro/config'
// ABOUT:
// We have to fetch settings from `.env`
// Which we have to do manually, see https://docs.astro.build/en/guides/configuring-astro/#environment-variables
//
// USAGE:
// `npm run dev` uses hybrid mode and keystatic()
// `npm run build` (server) is based on `.env` and has different settings for Netlify (CMS/Keystatic) vs. IONOS (Static site)
// `npm run build:local && npm run serve` overwrites the `.env` settings to have a local test case for what is on IONOS
import { loadEnv } from 'vite'
const { ASTRO_OUTPUT_MODE, ASTRO_USE_NETLIFY_ADAPTER } = loadEnv(
process.env.NODE_ENV,
process.cwd(),
'',
)
// CONFIG:
// https://astro.build/config
export default defineConfig({
site: 'https://www.radinfra.de/',
integrations: [
ASTRO_OUTPUT_MODE === 'static' ? undefined : keystatic(),
react(),
mdx(),
sitemap({
filter: (page) => !page.endsWith('README/'),
}),
],
vite: {
plugins: [tailwindcss()],
},
// On Netlify and during development we use `hybrid`, on GitHub Pages we use `static`.
// Using static makes sure features like Astro's redirecting work as expected.
// Docs https://docs.astro.build/en/basics/rendering-modes/
output: ASTRO_OUTPUT_MODE,
adapter: ASTRO_USE_NETLIFY_ADAPTER === 'true' ? netlify() : undefined,
redirects: {
'/contact': '/legal',
'/statistik/bundesland': '/statistik',
},
env: {
schema: {
ASTRO_OUTPUT_MODE: envField.enum({
values: ['static', 'server'],
access: 'secret',
context: 'server',
optional: false,
}),
ASTRO_USE_NETLIFY_ADAPTER: envField.boolean({
access: 'secret',
context: 'server',
optional: false,
}),
KEYSTATIC_STORAGE_KIND: envField.enum({
values: ['local', 'github'],
access: 'public',
context: 'client',
optional: false,
}),
ASTRO_ENV: envField.enum({
values: ['development', 'staging', 'production'],
access: 'public',
context: 'client',
optional: false,
}),
},
},
})