-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
60 lines (56 loc) · 1.6 KB
/
Copy pathnext.config.mjs
File metadata and controls
60 lines (56 loc) · 1.6 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
import bundleAnalyzer from '@next/bundle-analyzer'
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
unoptimized: true,
},
// Webpack configuration for bundle size tracking and code splitting
webpack: (config, { isServer }) => {
if (!isServer) {
// Add bundle size warnings for client bundles
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
cacheGroups: {
default: false,
vendors: false,
// Vendor chunk for large libraries
vendor: {
name: 'vendor',
chunks: 'all',
test: /node_modules/,
priority: 20,
},
// D3 chunk (large library)
d3: {
name: 'd3',
chunks: 'all',
test: /[\\/]node_modules[\\/](d3|topojson-client)[\\/]/,
priority: 30,
},
// React Query chunk
reactQuery: {
name: 'react-query',
chunks: 'all',
test: /[\\/]node_modules[\\/]@tanstack[\\/]react-query[\\/]/,
priority: 25,
},
// Radix UI components (can be large)
radix: {
name: 'radix-ui',
chunks: 'all',
test: /[\\/]node_modules[\\/]@radix-ui[\\/]/,
priority: 15,
},
},
},
}
}
return config
},
}
export default withBundleAnalyzer(nextConfig)