-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
133 lines (115 loc) · 3.69 KB
/
next.config.js
File metadata and controls
133 lines (115 loc) · 3.69 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
const { withSentryConfig } = require("@sentry/nextjs");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// Compiler optimizations
compiler: {
// Remove console.log in production
removeConsole: process.env.NODE_ENV === 'production' ? { exclude: ['error', 'warn'] } : false,
},
// Experimental features for faster builds and smaller bundles
experimental: {
// Enable optimized package imports for commonly used packages
optimizePackageImports: ['lucide-react', '@radix-ui/react-dialog', '@radix-ui/react-dropdown-menu', 'phosphor-react'],
},
// Image optimization configuration
images: {
// Support Reddit CDN for user avatars
remotePatterns: [
{
protocol: 'https',
hostname: 'styles.redditmedia.com',
},
{
protocol: 'https',
hostname: '*.redd.it',
},
{
protocol: 'https',
hostname: 'www.redditstatic.com',
},
],
// Use modern formats for better compression
formats: ['image/avif', 'image/webp'],
},
// Headers for caching static assets
async headers() {
return [
{
source: '/logo.png',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/:path*.png',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/:path*.ico',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
];
},
};
module.exports = withSentryConfig(withBundleAnalyzer(nextConfig), {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
// Use environment variables for Sentry configuration
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
// 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,
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers
tunnelRoute: "/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Disable Sentry webpack plugin if no auth token (for local development)
disableServerWebpackPlugin: !process.env.SENTRY_AUTH_TOKEN,
disableClientWebpackPlugin: !process.env.SENTRY_AUTH_TOKEN,
// Source maps configuration for Debug IDs
sourcemaps: {
// Delete source maps after uploading to Sentry (keeps them out of production bundles)
deleteSourcemapsAfterUpload: true,
},
// Release configuration
release: {
// Use git commit SHA for release versioning
name: process.env.VERCEL_GIT_COMMIT_SHA || process.env.SENTRY_RELEASE,
// Create release and associate commits
create: true,
// Finalize release after upload
finalize: true,
},
webpack: {
// Enables automatic instrumentation of Vercel Cron Monitors
automaticVercelMonitors: true,
// Tree-shaking options for reducing bundle size
treeshake: {
// Automatically tree-shake Sentry logger statements to reduce bundle size
removeDebugLogging: true,
},
},
});