-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
162 lines (139 loc) · 4.2 KB
/
next.config.js
File metadata and controls
162 lines (139 loc) · 4.2 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
/** @type {import('next').NextConfig} */
const nextConfig = {
// Source maps for production debugging and Lighthouse insights
productionBrowserSourceMaps: true,
// Performance optimizations
reactCompiler: true,
experimental: {
optimizePackageImports: ['framer-motion', 'react-icons'],
turbopackFileSystemCacheForDev: true,
optimizeCss: true,
},
// Turbopack configuration
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
// Compiler optimizations
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
// Image optimizations
images: {
formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 2592000,
qualities: [75, 90],
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
// Bundle optimization
webpack: (config) => {
// PDF file handling
config.module.rules.push({
test: /\.pdf$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
});
return config;
},
// Security headers
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'Content-Security-Policy',
value:
"default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://vercel.live https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https://vitals.vercel-insights.com https://vercel.live wss://ws-us3.pusher.com https://*.sentry.io; worker-src blob:; frame-ancestors 'self'; base-uri 'self'; form-action 'self';",
},
],
},
];
},
reactStrictMode: true,
outputFileTracingRoot: __dirname,
poweredByHeader: false,
compress: true,
};
// const nextConfig = {}
module.exports = nextConfig;
// Injected content via Sentry wizard below
const { withSentryConfig } = require('@sentry/nextjs');
module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
// Suppresses source map uploading logs during build
silent: true,
org: 'software-engineer-dn',
project: 'portfolio-nextjs',
// Source map configuration
sourcemaps: {
disable: process.env.NODE_ENV === 'development',
deleteSourcemapsAfterUpload: true,
},
// Error handling for API timeouts
errorHandler: (err) => {
console.warn('Sentry CLI warning:', err);
// Don't fail the build on Sentry API errors
return false;
},
// Release configuration to prevent timeouts
release: {
finalize: false,
},
// Deploy configuration
deploy: {
env: process.env.NODE_ENV,
},
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: '/monitoring',
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
}
);