-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
62 lines (58 loc) · 1.85 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
// @ts-nocheck
import { defineConfig } from 'astro/config';
import svelte from '@astrojs/svelte';
import { fileURLToPath } from 'url';
import path from 'path';
import sentry from '@sentry/astro';
// Get dirname in ESM
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Get backend URL from .env file or use default
// In Node.js config context, we must use process.env
const BACKEND_URL = process.env.PUBLIC_BACKEND_URL || process.env.BACKEND_URL || 'http://localhost:8888';
// https://astro.build/config
export default defineConfig({
// Use static mode for static site generation
output: 'static',
// Server config for development only
server: {
host: '0.0.0.0',
port: parseInt(process.env.PORT || '3000', 10),
},
integrations: [svelte(), sentry({
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENVIRONMENT,
release: process.env.SENTRY_RELEASE,
authToken: process.env.SENTRY_AUTH_TOKEN
})],
vite: {
define: {
// Define PUBLIC_BACKEND_URL for client-side code
'import.meta.env.PUBLIC_BACKEND_URL': JSON.stringify(BACKEND_URL),
},
resolve: {
alias: {
// Use absolute path for esm-env to avoid duplication
'esm-env': path.resolve(__dirname, 'src/utils/env.ts'),
'esm-env/node': path.resolve(__dirname, 'src/utils/env.ts'),
},
},
// Optimize build for production
build: {
// Generate sourcemaps for debugging
sourcemap: process.env.NODE_ENV === 'production' ? false : 'inline',
// Minify in production
minify: process.env.NODE_ENV === 'production',
// Improve chunk size
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
// Optimize bundle size
manualChunks: {
svelte: ['svelte'],
vendor: ['path', 'url']
}
}
}
}
}
});