-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
109 lines (104 loc) · 2.53 KB
/
next.config.js
File metadata and controls
109 lines (104 loc) · 2.53 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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
experimental: {
optimizePackageImports: ['@rainbow-me/rainbowkit', 'wagmi', 'viem'],
turbo: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Optimize bundle size
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
};
// Add support for WebAssembly
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
layers: true,
};
// Optimize for production
if (!dev && !isServer) {
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
web3: {
test: /[\\/]node_modules[\\/](wagmi|viem|@rainbow-me|@tanstack)[\\/]/,
name: 'web3',
chunks: 'all',
priority: 10,
},
ui: {
test: /[\\/]node_modules[\\/](react|react-dom|framer-motion)[\\/]/,
name: 'ui',
chunks: 'all',
priority: 5,
},
},
},
};
}
return config;
},
env: {
CUSTOM_KEY: process.env.CUSTOM_KEY,
},
images: {
domains: ['assets.coingecko.com', 'raw.githubusercontent.com', 'tokens.1inch.io'],
formats: ['image/webp', 'image/avif'],
},
headers: async () => {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()',
},
],
},
];
},
compress: true,
poweredByHeader: false,
generateEtags: false,
httpAgentOptions: {
keepAlive: true,
},
};
// Bundle analyzer
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer(nextConfig);