-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
179 lines (160 loc) · 3.56 KB
/
next.config.js
File metadata and controls
179 lines (160 loc) · 3.56 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
poweredByHeader: false,
// Production optimizations
compress: true,
generateEtags: true,
productionBrowserSourceMaps: false,
// TypeScript and ESLint - allow builds to proceed
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
// Minimal compiler options
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
// Fix for framer-motion and other ESM issues
transpilePackages: [
'framer-motion',
'lucide-react',
'@tanstack/react-query',
'react-hot-toast',
'zustand',
'zod',
'jose'
],
// Webpack optimizations for module loading
webpack: (config, { dev, isServer }) => {
// Fix for undefined module calls and node modules in browser
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
dns: false,
child_process: false,
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
os: false,
zlib: false,
http: false,
https: false,
};
}
// Suppress typescript-parser warnings
config.module.rules.push({
test: /node_modules\/typescript-parser/,
use: {
loader: 'null-loader'
}
});
// Better error handling for client-side chunks
if (!isServer) {
config.output.strictModuleErrorHandling = true;
config.output.pathinfo = dev;
}
// Fix HMR issues in development - limit concurrent connections
if (dev && !isServer) {
// Reduce HMR polling frequency to handle more connections
config.watchOptions = {
poll: 2000, // Increased from 1000ms
aggregateTimeout: 500, // Increased debounce
ignored: /node_modules/,
};
// Improve webpack caching for HMR with memory limits
config.cache = {
type: 'filesystem',
maxMemoryGenerations: 1, // Limit memory usage
buildDependencies: {
config: [__filename],
},
};
// Limit concurrent compilation for stability
config.parallelism = 2;
// Optimize for multiple users
config.optimization = {
...config.optimization,
moduleIds: 'deterministic',
chunkIds: 'deterministic',
};
}
// Optimize chunk loading
if (!dev && !isServer) {
config.optimization.splitChunks = {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
},
},
};
}
return config;
},
// Experimental features for better caching
experimental: {
optimizeCss: true,
},
// Enhanced caching configuration - optimized for multiple users
onDemandEntries: {
maxInactiveAge: 60 * 1000, // Increased from 25s to reduce rebuilds
pagesBufferLength: 5, // Increased buffer for more concurrent users
},
// Headers for better caching and performance
async headers() {
return [
{
source: '/_next/static/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/api/:path*',
headers: [
{
key: 'Cache-Control',
value: 'no-store, max-age=0',
},
],
},
];
},
// Minimal redirects
async redirects() {
return [
{
source: '/',
destination: '/dashboard',
permanent: false,
},
];
},
// Minimal rewrites for API proxy - temporarily disabled to let API routes handle requests
async rewrites() {
return [
// Temporarily disabled to allow API routes to handle Backstage requests
// {
// source: '/api/backstage/:path*',
// destination: `${process.env.BACKSTAGE_BACKEND_URL || 'http://localhost:4402'}/api/:path*`,
// },
];
},
};
module.exports = nextConfig;