-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathnext.config.ts
More file actions
232 lines (210 loc) · 9 KB
/
next.config.ts
File metadata and controls
232 lines (210 loc) · 9 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import NextBundleAnalyzer from '@next/bundle-analyzer'
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'
import type { Configuration as WebpackConfiguration } from 'webpack'
const nextConfig: NextConfig = {
images: {
dangerouslyAllowSVG: true,
qualities: [50, 75, 85, 100],
localPatterns: [
// Allow any query on the proxy route
{ pathname: '/api/proxy-image' },
{ pathname: '/_next/**' },
{ pathname: '/placeholder/**' },
{ pathname: '/assets/android-app/**' },
],
remotePatterns: [
{ protocol: 'https', hostname: 'placehold.co', pathname: '/**' },
{ protocol: 'https', hostname: 'media.rawg.io', pathname: '/**' },
{ protocol: 'https', hostname: '*.clerk.com', pathname: '/**' },
{ protocol: 'https', hostname: '*.clerk.accounts.dev', pathname: '/**' },
{ protocol: 'https', hostname: 'cdn.thegamesdb.net', pathname: '/**' },
{ protocol: 'https', hostname: 'images.igdb.com', pathname: '/**' },
{ protocol: 'https', hostname: 'assets.nintendo.com', pathname: '/**' },
{ protocol: 'https', hostname: 'storage.ko-fi.com', pathname: '/**' },
{ protocol: 'https', hostname: 'ko-fi.com', pathname: '/**' },
],
},
allowedDevOrigins: ['dev.emuready.com'],
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
experimental: {
optimizeCss: true,
optimizePackageImports: [
'@clerk/nextjs',
'@tanstack/react-query',
'date-fns',
'framer-motion',
'lucide-react',
'@radix-ui/react-dialog',
'@radix-ui/react-popover',
'@radix-ui/react-tooltip',
'@dnd-kit/core',
'@dnd-kit/sortable',
'react-hook-form',
'remeda',
'@/components/ui',
'@/components/icons',
'@/hooks',
'@/lib',
'@/utils',
],
},
serverExternalPackages: ['@prisma/client', 'jsdom', 'markdown-it', 'dompurify'],
outputFileTracingIncludes: {
'/*': ['docs/**/*.md'],
},
outputFileTracingExcludes: {
// apply to all server routes
'/*': [
'backups/**/*',
'test-results/**/*',
'playwright-report/**/*',
'blob-report/**/*',
'coverage/**/*',
'**/*.sql',
'**/*.pgdump',
'**/*.data.sql',
'**/*.zip',
'**/*.trace.zip',
'**/*.webm',
'**/*.png',
'tsconfig.tsbuildinfo',
'.next/cache/**/*',
'node_modules/**/*.md',
'node_modules/**/*.txt',
'node_modules/**/README*',
'node_modules/**/CHANGELOG*',
'node_modules/**/LICENSE*',
'node_modules/**/*.test.*',
'node_modules/**/*.spec.*',
'node_modules/**/test/**/*',
'node_modules/**/tests/**/*',
'node_modules/**/examples/**/*',
'node_modules/**/docs/**/*',
],
},
eslint: {
dirs: ['src', 'tests'],
},
webpack: (config: WebpackConfiguration) => {
config.module?.rules?.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
})
return config
},
async headers() {
const headers = [
// Service worker files should never be cached by the browser
{
source: '/service-worker.js',
headers: [{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate' }],
},
{
source: '/sw-register.js',
headers: [{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate' }],
},
// Static assets with hash - cache immutable
{
source: '/_next/static/:path*',
headers: [{ key: 'Cache-Control', value: 'public, max-age=31536000, immutable' }],
},
// Images and other assets - cache with revalidation
{
source: '/favicon/:path*',
headers: [{ key: 'Cache-Control', value: 'public, max-age=86400, must-revalidate' }],
},
{
source: '/api/mobile/:path*',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate' },
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET, POST, PUT, DELETE, OPTIONS' },
{
key: 'Access-Control-Allow-Headers',
value: 'Content-Type, Authorization, x-trpc-source',
},
{ key: 'Access-Control-Expose-Headers', value: 'x-trpc-source' },
],
},
// tRPC endpoints are dynamic; prevent intermediary/proxy caching
{
source: '/api/trpc/:path*',
headers: [{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate' }],
},
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://static.cloudflareinsights.com https://va.vercel-scripts.com https://*.clerk.com https://*.clerk.accounts.dev https://clerk.emuready.com https://challenges.cloudflare.com https://vercel.live https://*.vercel.live https://storage.ko-fi.com https://ko-fi.com https://unpkg.com",
"style-src 'self' 'unsafe-inline' https://*.clerk.com https://*.clerk.accounts.dev https://clerk.emuready.com https://storage.ko-fi.com https://fonts.googleapis.com https://unpkg.com",
"img-src 'self' data: https://placehold.co https://*.clerk.com https://*.clerk.accounts.dev https://img.clerk.com https://clerk.emuready.com https://cdn.thegamesdb.net https://images.igdb.com https://media.rawg.io https://www.googletagmanager.com https://assets.nintendo.com https://*.google-analytics.com https://storage.ko-fi.com https://vercel.com https://files.catbox.moe",
"font-src 'self' https://*.clerk.com https://*.clerk.accounts.dev https://clerk.emuready.com https://fonts.gstatic.com https://fonts.googleapis.com https://vercel.live data:",
"connect-src 'self' https://*.google-analytics.com https://www.googletagmanager.com https://api.mymemory.translated.net https://fonts.googleapis.com https://fonts.gstatic.com https://*.clerk.com https://*.clerk.accounts.dev https://clerk.emuready.com wss://*.clerk.accounts.dev wss://clerk.emuready.com https://va.vercel-scripts.com https://challenges.cloudflare.com https://storage.ko-fi.com https://clerk-telemetry.com https://vercel.live https://*.vercel.live wss://ws-us3.pusher.com https://api.github.com https://*.ingest.sentry.io https://*.ingest.us.sentry.io https://*.r2.cloudflarestorage.com https://cdn.emuready.com https://retrocatalog.com",
"frame-src 'self' blob: https://*.clerk.com https://*.clerk.accounts.dev https://clerk.emuready.com https://challenges.cloudflare.com https://vercel.live https://*.vercel.live https://ko-fi.com",
"worker-src 'self' blob:",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
'block-all-mixed-content',
'upgrade-insecure-requests',
].join('; '),
},
{ key: 'X-XSS-Protection', value: '1; mode=block' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
],
},
]
// In dev disable HTML caching to avoid stale content via proxies
if (process.env.NODE_ENV !== 'production') {
headers.push({
// All routes except static assets and API
source: '/((?!_next|api|favicon|service-worker\\.js|sw-register\\.js).*)',
headers: [
{ key: 'Cache-Control', value: 'no-store, no-cache, must-revalidate' },
{ key: 'Pragma', value: 'no-cache' },
],
})
}
return headers
},
}
const withBundleAnalyzer = NextBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
export default withSentryConfig(withBundleAnalyzer(nextConfig), {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: 'hexelnet',
project: 'emuready',
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
// tunnelRoute: "/monitoring",
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
})