-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathnext.config.js
More file actions
133 lines (124 loc) · 3.82 KB
/
Copy pathnext.config.js
File metadata and controls
133 lines (124 loc) · 3.82 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
126
127
128
129
130
131
132
133
/** @type {import('next').NextConfig} */
const path = require('path');
const { i18n } = require('./next-i18next.config');
// Validate environment variables at build time.
// This ensures missing/invalid vars are caught early with a clear error message.
const { z } = require('zod');
const envSchema = z.object({
NEXT_PUBLIC_STELLAR_RECEIVER_ADDRESS: z
.string()
.min(56, 'Must be a valid Stellar public key (56 chars)')
.max(56, 'Must be a valid Stellar public key (56 chars)')
.regex(/^G[A-Z2-7]{55}$/, 'Must be a valid Stellar public key (starts with G)'),
NEXT_PUBLIC_BACKEND_URL: z.string().url().optional(),
NEXT_PUBLIC_WS_URL: z.string().url().optional(),
NEXT_PUBLIC_API_URL: z.string().url().optional(),
NEXT_PUBLIC_API_BASE_URL: z.string().url().optional(),
NEXT_PUBLIC_VAPID_PUBLIC_KEY: z.string().min(1).optional(),
NEXT_PUBLIC_SOCKET_URL: z.string().url().optional(),
});
// Validate environment variables at build/dev time.
// Provides a valid testnet default for local development and CI.
const parsed = envSchema.safeParse({
...process.env,
NEXT_PUBLIC_STELLAR_RECEIVER_ADDRESS: process.env.NEXT_PUBLIC_STELLAR_RECEIVER_ADDRESS || 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWNA',
});
if (!parsed.success) {
const errors = parsed.error.errors
.map((e) => ` ${e.path.join('.')}: ${e.message}`)
.join('\n');
throw new Error(`❌ Invalid environment variables:\n${errors}\n\nSee .env.example for reference.`);
}
const nextConfig = {
// Enable standalone output for Docker container builds
output: 'standalone',
typescript: {
// Ignore TS build errors — pre-existing type issues across the codebase
ignoreBuildErrors: true,
},
eslint: {
// Ignore ESLint errors during build — pre-existing issues across the codebase
ignoreDuringBuilds: true,
},
transpilePackages: ['three', '@react-three/fiber', '@react-three/drei'],
env: {
NEXT_PUBLIC_STELLAR_RECEIVER_ADDRESS: process.env.NEXT_PUBLIC_STELLAR_RECEIVER_ADDRESS,
},
i18n,
async rewrites() {
return [
{
source: '/api/:path*',
destination: '/api/:path*',
},
];
},
// Performance monitoring configuration
webpack: (config, { isServer }) => {
// Enable bundle analysis in production
if (process.env.ANALYZE === 'true') {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
})
);
}
// Performance optimizations
// Stub native-only modules and broken packages that can't run in browser/build
config.resolve.alias = {
...config.resolve.alias,
brainflow: false,
'@creit.tech/stellar-wallets-kit': path.resolve(__dirname, 'src/stubs/stellar-wallets-kit.ts'),
};
config.optimization.splitChunks = {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
enforce: true,
},
},
};
return config;
},
// Enable compression
compress: true,
// Enable image optimization
images: {
domains: ['localhost'],
formats: ['image/webp', 'image/avif'],
},
// Performance headers
async headers() {
return [
{
source: '/_next/static/(.*)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/api/(.*)',
headers: [
{
key: 'Cache-Control',
value: 'no-cache, no-store, must-revalidate',
},
],
},
];
},
};
module.exports = nextConfig;