-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.production.mjs
More file actions
125 lines (107 loc) · 2.71 KB
/
Copy pathastro.config.production.mjs
File metadata and controls
125 lines (107 loc) · 2.71 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// @ts-check
/**
* Production Astro Configuration
*
* Optimized build configuration for production deployment with:
* - Asset minification
* - Code splitting
* - Tree shaking
* - Bundle optimization
*
* Part of T144: Minify and bundle assets for production
*/
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import tailwind from '@astrojs/tailwind';
// Production-optimized Astro configuration
export default defineConfig({
site: 'https://mystic-ecom.pages.dev',
output: 'server',
adapter: cloudflare({
mode: 'directory',
}),
integrations: [
tailwind({
applyBaseStyles: false,
}),
],
server: {
port: 4321,
host: true,
},
// Build optimization
build: {
// Inline small assets (< 4KB) as base64
inlineStylesheets: 'auto',
// Asset naming with content hash for cache busting
assets: '_astro',
},
// Vite build optimizations
vite: {
build: {
// Minification
minify: 'esbuild',
cssMinify: true,
// Code splitting
rollupOptions: {
output: {
// Manual chunks for better caching
manualChunks: (id) => {
// Vendor chunks
if (id.includes('node_modules')) {
// Separate large libraries
if (id.includes('stripe')) return 'vendor-stripe';
if (id.includes('redis')) return 'vendor-redis';
if (id.includes('pg')) return 'vendor-pg';
// Other vendor code
return 'vendor';
}
// Component chunks
if (id.includes('/components/')) {
return 'components';
}
// Lib chunks
if (id.includes('/lib/')) {
return 'lib';
}
},
// Asset naming with hash
entryFileNames: '_astro/[name].[hash].js',
chunkFileNames: '_astro/[name].[hash].js',
assetFileNames: '_astro/[name].[hash][extname]',
},
},
// Chunk size warnings
chunkSizeWarningLimit: 500, // 500 KB
// Source maps (disable in production for smaller bundles)
sourcemap: false,
// Target modern browsers
target: 'es2020',
// Enable tree shaking
cssCodeSplit: true,
},
// Optimization
optimizeDeps: {
include: [
'stripe',
'redis',
'pg',
'bcrypt',
'cookie',
],
},
// SSR externals
ssr: {
external: ['@redis/client', 'redis'],
noExternal: ['stripe'],
},
// Performance optimizations
server: {
fs: {
strict: false,
},
},
},
// Compression (handled by Cloudflare Pages)
compressHTML: true,
});