-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathnext.config.js
More file actions
196 lines (187 loc) · 5.41 KB
/
Copy pathnext.config.js
File metadata and controls
196 lines (187 loc) · 5.41 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
module.exports = {
// Enable production optimizations in development
// This will help with more accurate performance testing
productionBrowserSourceMaps: false,
// Optimize bundle size
compiler: {
removeConsole: process.env.NODE_ENV === "production",
},
// Modular imports / tree-shaking for heavy dependencies. Many MUI components
// and icons get pulled in via named imports; without this, the full package
// ships in the initial bundle. Also covers lodash (use lodash-es per import
// path too) and date-fns.
experimental: {
optimizePackageImports: [
"@mui/material",
"@mui/icons-material",
"@mui/lab",
"@mui/x-data-grid",
"@mui/x-date-pickers",
"date-fns",
"lodash",
"react-icons",
],
},
// Rewrites configuration
async rewrites() {
return [
{
source: "/hack/:path*/sponsor",
destination: "/sponsor",
},
];
},
// Redirects: deprecated paths → canonical
async redirects() {
return [
// Redirect non-www frontend subdomain → www (canonical host).
// frontend.ohack.dev is indexed in GSC but should not be.
{
source: "/:path*",
has: [{ type: "host", value: "frontend.ohack.dev" }],
destination: "https://www.ohack.dev/:path*",
permanent: true,
},
// judge-keyword doorway pages → canonical landing page.
// These 3 pages were deleted (June 2026); 301s preserve their link equity.
{
source: "/hackathon-judge",
destination: "/hackathon-judge-opportunities",
permanent: true,
},
{
source: "/hackathon-judging",
destination: "/hackathon-judge-opportunities",
permanent: true,
},
{
source: "/hackathon-judging-opportunities",
destination: "/hackathon-judge-opportunities",
permanent: true,
},
// Pre-existing legacy variants
{
source: "/judge-a-hackathon",
destination: "/hackathon-judge-opportunities",
permanent: true,
},
{
source: "/judge-hackathon",
destination: "/hackathon-judge-opportunities",
permanent: true,
},
// Legacy event slug aliases: season-YYYY → YYYY_season (years ≤ 2025 only).
// GSC data: /hack/2025_fall has 13k impressions; /hack/fall-2025 is a
// soft-404 with 118 impressions. 2026+ events use dash IDs natively.
// Generated as a static list because Next.js path-to-regexp cannot put two
// named params in a destination without literal text between them.
...['fall','spring','summer','winter'].flatMap(season =>
['2013','2014','2015','2016','2017','2018','2019','2020','2021','2022','2023','2024','2025'].flatMap(year => [
{ source: `/hack/${season}-${year}`, destination: `/hack/${year}_${season}`, permanent: true },
{ source: `/hack/${season}-${year}/:path*`, destination: `/hack/${year}_${season}/:path*`, permanent: true },
])
),
// Short alias: /hack/<event>/mentor → the mentor check-in one-stop-shop.
// `:event_id` matches a single segment, so this never collides with the
// team-level /hack/<event>/team/<team_id>/mentor sub-page. Temporary (307):
// it's an operational, auth-gated page (no SEO value) and the alias may
// evolve, so we avoid browsers hard-caching a 308.
{
source: "/hack/:event_id/mentor",
destination: "/hack/:event_id/mentor-checkin",
permanent: false,
},
];
},
// Optimize images
images: {
formats: ["image/avif", "image/webp"],
minimumCacheTTL: 86400,
remotePatterns: [
{
protocol: "https",
hostname: "*.giphy.com",
port: "",
pathname: "/media/**",
},
{
protocol: "https",
hostname: "i.imgur.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "avatars.githubusercontent.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "images.squarespace-cdn.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "avatars.slack-edge.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "secure.gravatar.com",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "cdn.ohack.dev",
port: "",
pathname: "/**",
},
],
},
// Improve caching headers
async headers() {
return [
{
source: "/:all*(svg|jpg|png|webp|avif|gif|ico)",
locale: false,
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/_next/static/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/_next/image/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
source: "/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=3600, must-revalidate",
},
],
},
];
},
};