-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
107 lines (97 loc) · 2.87 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import 'dotenv/config';
import { existsSync } from 'node:fs';
import { rm } from 'node:fs/promises';
import { join } from 'node:path';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import tailwind from '@astrojs/tailwind';
import compress from '@playform/compress';
import sentry from '@sentry/astro';
import spotlightjs from '@spotlightjs/astro';
import { defineConfig, envField } from 'astro/config';
import icon from 'astro-icon';
import metaTags from 'astro-meta-tags';
// import node from '@astrojs/node';
import vercel from '@astrojs/vercel/serverless';
// https://astro.build/config
export default defineConfig({
site: getSiteUrl(),
// i18n: {
// defaultLocale: 'en',
// locales: ['es', 'en'],
// },
output: 'server',
// adapter: node({
// mode: 'standalone',
// }),
adapter: vercel({
imageService: true,
}),
security: {
checkOrigin: false,
},
env: {
schema: {
PUBLIC_UMAMI_WEBSITE_ID: envField.string({ context: 'client', access: 'public', optional: true }),
PUBLIC_POSTHOG_API_HOST: envField.string({ context: 'client', access: 'public', optional: true, url: true }),
PUBLIC_POSTHOG_API_KEY: envField.string({ context: 'client', access: 'public', optional: true }),
PUBLIC_SENTRY_DSN: envField.string({ context: 'client', access: 'public', optional: true, url: true }),
PRIVATE_SENTRY_AUTH_TOKEN: envField.string({ context: 'server', access: 'secret', optional: true }),
},
},
integrations: [
metaTags(),
mdx(),
icon(),
tailwind(),
sitemap({ filter: (url) => new URL(url).pathname === '/' }),
{
name: 'remove-asset-sites',
hooks: {
'astro:build:done': async ({ dir }) => {
await Promise.all([removeIfExists(join(dir.pathname, 'og')), removeIfExists(join(dir.pathname, 'pdf'))]);
},
},
},
compress({
CSS: false,
HTML: {
'html-minifier-terser': {
minifyCSS: false,
},
},
}),
sentry({
dsn: 'https://[email protected]/4506597307056128',
sourceMapsUploadOptions: {
project: 'martincollado-dev',
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
spotlightjs(),
],
});
async function removeIfExists(path: string) {
if (existsSync(path)) {
await rm(path, { recursive: true });
}
}
function getSiteUrl() {
if (process.env.ASTRO_SITE) {
return process.env.ASTRO_SITE;
}
if (process.env.NETLIFY) {
return process.env.URL;
}
if (process.env.RENDER) {
return process.env.RENDER_EXTERNAL_URL;
}
if (process.env.CF_PAGES) {
return process.env.CF_PAGES_URL;
}
if (process.env.CI && process.env.CI_CHECKS !== 'true') {
console.error('Site URL not not found. Please set the ASTRO_SITE environment variable.');
process.exit(1);
}
return 'http://localhost:4321';
}