-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
207 lines (199 loc) · 6.75 KB
/
next.config.ts
File metadata and controls
207 lines (199 loc) · 6.75 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import type { NextConfig } from "next";
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const nextConfig: NextConfig = {
/* config options here */
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
// Optimize bundle size
experimental: {
optimizePackageImports: ['@saros-finance/dlmm-sdk'],
},
// Turbopack configuration
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
// External packages for serverless functions
// Note: Using webpack externals instead to avoid conflicts with transpilePackages
// Fix routes manifest issue
outputFileTracingRoot: process.cwd(),
// Exclude large dependencies from serverless functions
outputFileTracingExcludes: {
'*': [
'./node_modules/@next/swc-linux-x64-gnu/**/*',
'./node_modules/@next/swc-linux-x64-musl/**/*',
'./node_modules/next/dist/**/*',
'./node_modules/typescript/lib/**/*',
'./node_modules/@img/sharp/**/*',
'./node_modules/@img/sharp-libvips-linuxmusl-x64/**/*',
'./node_modules/@img/sharp-libvips-linux-x64/**/*',
'./node_modules/@esbuild/linux-x64/**/*',
'./node_modules/esbuild/bin/**/*',
'./node_modules/@saros-finance/dlmm-sdk/**/*',
'./node_modules/@solana/**/*',
'./node_modules/@coral-xyz/**/*',
'./node_modules/bn.js/**/*',
'./node_modules/lodash/**/*',
'./node_modules/@babel/parser/**/*',
'./node_modules/axe-core/**/*',
'./node_modules/prettier/**/*',
'./node_modules/eslint-plugin-import/**/*',
'./node_modules/eslint-plugin-react/**/*',
'./node_modules/@noble/**/*',
'./node_modules/@ethereumjs/**/*',
'./node_modules/ripple-binary-codec/**/*',
'./node_modules/styled-jsx/**/*',
'./node_modules/rxjs/**/*',
'./node_modules/graphemer/**/*',
'./node_modules/@tybys/wasm-util/**/*',
],
},
// Reduce bundle size
webpack: (config, { isServer }) => {
// Exclude only the most critical large dependencies from serverless functions
if (isServer) {
config.externals = config.externals || [];
config.externals.push({
// Only exclude the largest dependencies that cause 250MB limit
'@next/swc-linux-x64-gnu': 'commonjs @next/swc-linux-x64-gnu',
'@next/swc-linux-x64-musl': 'commonjs @next/swc-linux-x64-musl',
'next/dist': 'commonjs next/dist',
'typescript/lib': 'commonjs typescript/lib',
'@img/sharp-libvips-linuxmusl-x64': 'commonjs @img/sharp-libvips-linuxmusl-x64',
'@img/sharp-libvips-linux-x64': 'commonjs @img/sharp-libvips-linux-x64',
'@esbuild/linux-x64': 'commonjs @esbuild/linux-x64',
'esbuild/bin': 'commonjs esbuild/bin',
});
}
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
stream: false,
util: false,
buffer: false,
process: false,
};
// Exclude large packages from client-side bundle
config.resolve.alias = {
...config.resolve.alias,
'axe-core': false,
'prettier': false,
'eslint-plugin-import': false,
'eslint-plugin-react': false,
'styled-jsx': false,
'rxjs': false,
'graphemer': false,
'@tybys/wasm-util': false,
'@react-native-async-storage/async-storage': false,
'@react-native/assets-registry': false,
'@react-native/codegen': false,
'@react-native/community-cli-plugin': false,
'@react-native/debugger-frontend': false,
'react-native': false,
'react-native-web': false,
};
// Exclude React Native modules
config.externals = config.externals || [];
config.externals.push({
'@react-native-async-storage/async-storage': 'commonjs @react-native-async-storage/async-storage',
'@react-native/assets-registry': 'commonjs @react-native/assets-registry',
'@react-native/codegen': 'commonjs @react-native/codegen',
'@react-native/community-cli-plugin': 'commonjs @react-native/community-cli-plugin',
'@react-native/debugger-frontend': 'commonjs @react-native/debugger-frontend',
'react-native': 'commonjs react-native',
'react-native-web': 'commonjs react-native-web',
});
}
// Optimize for production
if (!isServer) {
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
minSize: 20000,
maxSize: 200000, // 200KB per chunk
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
maxSize: 200000,
priority: 1,
},
solana: {
test: /[\\/]node_modules[\\/]@solana[\\/]/,
name: 'solana',
chunks: 'all',
priority: 20,
maxSize: 200000,
},
supabase: {
test: /[\\/]node_modules[\\/]@supabase[\\/]/,
name: 'supabase',
chunks: 'all',
priority: 20,
maxSize: 200000,
},
dlmm: {
test: /[\\/]node_modules[\\/]@saros-finance[\\/]/,
name: 'dlmm',
chunks: 'all',
priority: 20,
maxSize: 200000,
},
react: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'react',
chunks: 'all',
priority: 30,
maxSize: 200000,
},
// Exclude large utility libraries from main bundle
utils: {
test: /[\\/]node_modules[\\/](lodash|moment|date-fns)[\\/]/,
name: 'utils',
chunks: 'all',
priority: 10,
maxSize: 100000,
},
},
},
usedExports: true,
sideEffects: false,
// Enable tree shaking
providedExports: true,
concatenateModules: true,
};
}
return config;
},
// Enable compression
compress: true,
// Optimize images
images: {
formats: ['image/webp', 'image/avif'],
},
// Disable standalone to use Vercel's built-in optimizations
// output: 'standalone',
};
export default withBundleAnalyzer(nextConfig);