-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
65 lines (63 loc) · 1.89 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
import { defineConfig, envField, passthroughImageService } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import graphql from '@rollup/plugin-graphql';
import sitemap from '@astrojs/sitemap';
import type { PluginOption } from 'vite';
import { isPreview } from './config/preview';
import pkg from './package.json';
const productionUrl = `https://${ pkg.name }.pages.dev`; // overwrite if you have a custom domain
const localhostPort = 4323; // 4323 is "head" in T9
export const siteUrl = process.env.CF_PAGES
? (process.env.CF_PAGES_BRANCH === 'main')
? productionUrl
: process.env.CF_PAGES_URL
: `http://localhost:${localhostPort}`;
// https://astro.build/config
export default defineConfig({
adapter: cloudflare({
platformProxy: {
enabled: true,
},
}),
env: {
schema: {
DATOCMS_READONLY_API_TOKEN: envField.string({
context: 'server',
access: 'secret',
default: process.env.DATOCMS_READONLY_API_TOKEN
}),
HEAD_START_PREVIEW_SECRET: envField.string({
context: 'server',
access: 'secret',
default: process.env.HEAD_START_PREVIEW_SECRET
}),
HEAD_START_PREVIEW: envField.boolean({
context: 'server',
access: 'secret',
default: isPreview
}),
PUBLIC_IS_PRODUCTION: envField.boolean({
context: 'server',
access: 'public',
default: process.env.NODE_ENV === 'production'
})
}
},
image: {
// cloudflare is not supported by the Astro image service
// @see https://docs.astro.build/en/guides/images/#configure-no-op-passthrough-service
service: passthroughImageService()
},
integrations: [sitemap()],
output: isPreview ? 'server' : 'static',
server: { port: localhostPort },
site: siteUrl,
vite: {
plugins: [
graphql() as PluginOption,
],
optimizeDeps: {
exclude: ['msw'],
}
},
});