generated from JayRichh/next-temploot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
153 lines (143 loc) · 3.42 KB
/
next.config.js
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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
poweredByHeader: false,
// Image optimization
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'steamcdn-a.akamaihd.net',
},
{
protocol: 'https',
hostname: 'avatars.steamstatic.com',
}
],
formats: ['image/avif', 'image/webp'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 60,
},
// Optimize build output
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
// Performance optimizations
experimental: {
optimizeCss: true,
optimizePackageImports: ['lucide-react', '@react-three/drei'],
webVitalsAttribution: ['CLS', 'LCP'],
strictNextHead: true,
},
// Vercel specific optimizations
env: {
VERCEL_URL: process.env.VERCEL_URL,
},
// Headers for security and caching
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin'
},
{
key: 'Cache-Control',
value: process.env.NODE_ENV === 'production' ? 'public, max-age=31536000, immutable' : 'no-cache, no-store, must-revalidate'
}
],
},
{
source: '/(fonts|images)/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
},
{
source: '/api/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=60, stale-while-revalidate=300'
}
]
}
];
},
// Ensure sitemap and robots.txt are handled correctly
async rewrites() {
return [
{
source: '/sitemap.xml',
destination: '/api/sitemap',
},
{
source: '/robots.txt',
destination: '/api/robots',
},
];
},
// Production build configuration
webpack: (config, { dev, isServer }) => {
if (!dev && !isServer) {
// Exclude example pages from production build
config.module.rules.push({
test: /\.(js|jsx|ts|tsx)$/,
exclude: [
/node_modules/,
/src\/app\/examples/,
/src\/app\/three/
],
});
// Optimize CSS
config.optimization.splitChunks.cacheGroups.styles = {
name: 'styles',
test: /\.(css|scss)$/,
chunks: 'all',
enforce: true,
};
}
return config;
},
// Exclude paths from production
async redirects() {
if (process.env.NODE_ENV === 'production') {
return [
{
source: '/examples/:path*',
destination: '/404',
permanent: true,
},
{
source: '/three/:path*',
destination: '/404',
permanent: true,
}
];
}
return [];
}
};
module.exports = nextConfig;