1- /* eslint-disable @typescript-eslint/no-var-requires */
1+ import type { SentryBuildOptions } from "@sentry/nextjs" ;
2+ import type { NextConfig } from "next" ;
3+ import type { RemotePattern } from "next/dist/shared/lib/image-config" ;
4+ import FRAMER_PATHS from "./framer-rewrites" ;
5+ import getRedirects from "./redirects" ;
26
37const ContentSecurityPolicy = `
48 default-src 'self';
@@ -37,15 +41,9 @@ const securityHeaders = [
3741 } ,
3842] ;
3943
40- const redirects = require ( "./redirects" ) ;
41- const FRAMER_PATHS = require ( "./framer-rewrites" ) ;
42-
43- /**
44- * @returns {import('next').RemotePattern[] }
45- */
4644function determineIpfsGateways ( ) {
4745 // add the clientId ipfs gateways
48- const remotePatterns = [ ] ;
46+ const remotePatterns : RemotePattern [ ] = [ ] ;
4947 if ( process . env . API_ROUTES_CLIENT_ID ) {
5048 remotePatterns . push ( {
5149 protocol : "https" ,
@@ -84,23 +82,39 @@ function determineIpfsGateways() {
8482 return remotePatterns ;
8583}
8684
87- /** @type {import('next').NextConfig } */
88- const moduleExports = {
89- webpack : ( config , { dev } ) => {
90- if ( config . cache && ! dev ) {
91- config . cache = Object . freeze ( {
92- type : "memory" ,
93- } ) ;
94- config . cache . maxMemoryGenerations = 0 ;
95- }
96- config . externals . push ( "pino-pretty" ) ;
97- config . module = {
98- ...config . module ,
99- exprContextCritical : false ,
100- } ;
101- // Important: return the modified config
102- return config ;
103- } ,
85+ const SENTRY_OPTIONS : SentryBuildOptions = {
86+ // For all available options, see:
87+ // https://github.com/getsentry/sentry-webpack-plugin#options
88+
89+ org : "thirdweb-dev" ,
90+ project : "dashboard" ,
91+ // An auth token is required for uploading source maps.
92+ authToken : process . env . SENTRY_AUTH_TOKEN ,
93+ // Suppresses source map uploading logs during build
94+ silent : true ,
95+ // For all available options, see:
96+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
97+
98+ // Upload a larger set of source maps for prettier stack traces (increases build time)
99+ widenClientFileUpload : true ,
100+
101+ // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
102+ tunnelRoute : "/err" ,
103+
104+ // Hides source maps from generated client bundles
105+ hideSourceMaps : true ,
106+
107+ // Automatically tree-shake Sentry logger statements to reduce bundle size
108+ disableLogger : true ,
109+
110+ // Enables automatic instrumentation of Vercel Cron Monitors.
111+ // See the following for more information:
112+ // https://docs.sentry.io/product/crons/
113+ // https://vercel.com/docs/cron-jobs
114+ automaticVercelMonitors : false ,
115+ } ;
116+
117+ const baseNextConfig : NextConfig = {
104118 async headers ( ) {
105119 return [
106120 {
@@ -117,7 +131,7 @@ const moduleExports = {
117131 ] ;
118132 } ,
119133 async redirects ( ) {
120- return redirects ( ) ;
134+ return getRedirects ( ) ;
121135 } ,
122136 async rewrites ( ) {
123137 return [
@@ -151,74 +165,57 @@ const moduleExports = {
151165 ...determineIpfsGateways ( ) ,
152166 ] ,
153167 } ,
154- reactStrictMode : true ,
155- experimental : {
156- scrollRestoration : true ,
157- webpackBuildWorker : true ,
158- serverSourceMaps : false ,
159- } ,
160- cacheMaxMemorySize : 0 ,
161168 compiler : {
162169 emotion : true ,
163170 } ,
164- productionBrowserSourceMaps : false ,
171+ reactStrictMode : true ,
165172} ;
166173
167- const { withSentryConfig } = require ( "@sentry/nextjs" ) ;
168- const { withPlausibleProxy } = require ( "next-plausible" ) ;
169-
170- // we only want sentry on production environments
171- const wSentry =
172- process . env . NODE_ENV === "production" ? withSentryConfig : ( x ) => x ;
173-
174- const withBundleAnalyzer = require ( "@next/bundle-analyzer" ) ( {
175- enabled : process . env . ANALYZE === "true" ,
176- } ) ;
177-
178- module . exports = withBundleAnalyzer (
179- withPlausibleProxy ( {
180- customDomain : "https://pl.thirdweb.com" ,
181- scriptName : "pl" ,
182- } ) (
183- wSentry ( moduleExports , {
184- // For all available options, see:
185- // https://github.com/getsentry/sentry-webpack-plugin#options
186-
187- org : "thirdweb-dev" ,
188- project : "dashboard" ,
189- // An auth token is required for uploading source maps.
190- authToken : process . env . SENTRY_AUTH_TOKEN ,
191- // Suppresses source map uploading logs during build
192- silent : true ,
193- // For all available options, see:
194- // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
195-
196- // Upload a larger set of source maps for prettier stack traces (increases build time)
197- widenClientFileUpload : true ,
198-
199- // Transpiles SDK to be compatible with IE11 (increases bundle size)
200- transpileClientSDK : false ,
201-
202- // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
203- tunnelRoute : "/err" ,
204-
205- // Hides source maps from generated client bundles
206- hideSourceMaps : true ,
207-
208- // Automatically tree-shake Sentry logger statements to reduce bundle size
209- disableLogger : true ,
210-
211- // Enables automatic instrumentation of Vercel Cron Monitors.
212- // See the following for more information:
213- // https://docs.sentry.io/product/crons/
214- // https://vercel.com/docs/cron-jobs
215- automaticVercelMonitors : false ,
174+ function getConfig ( ) : NextConfig {
175+ if ( process . env . NODE_ENV === "production" ) {
176+ // eslint-disable-next-line @typescript-eslint/no-var-requires
177+ const withBundleAnalyzer = require ( "@next/bundle-analyzer" ) ( {
178+ enabled : process . env . ANALYZE === "true" ,
179+ } ) ;
180+ // eslint-disable-next-line @typescript-eslint/no-var-requires
181+ const { withPlausibleProxy } = require ( "next-plausible" ) ;
182+ // eslint-disable-next-line @typescript-eslint/no-var-requires
183+ const { withSentryConfig } = require ( "@sentry/nextjs" ) ;
184+ return withBundleAnalyzer (
185+ withPlausibleProxy ( {
186+ customDomain : "https://pl.thirdweb.com" ,
187+ scriptName : "pl" ,
188+ } ) (
189+ withSentryConfig (
190+ {
191+ ...baseNextConfig ,
192+ experimental : {
193+ webpackBuildWorker : true ,
194+ } ,
195+ // @ts -expect-error - this is a valid option
196+ webpack : ( config , { dev } ) => {
197+ if ( config . cache && ! dev ) {
198+ config . cache = Object . freeze ( {
199+ type : "filesystem" ,
200+ maxMemoryGenerations : 0 ,
201+ } ) ;
202+ }
203+ config . externals . push ( "pino-pretty" ) ;
204+ config . module = {
205+ ...config . module ,
206+ exprContextCritical : false ,
207+ } ;
208+ // Important: return the modified config
209+ return config ;
210+ } ,
211+ } ,
212+ SENTRY_OPTIONS ,
213+ ) ,
214+ ) ,
215+ ) ;
216+ }
217+ // otherwise return the base
218+ return baseNextConfig ;
219+ }
216220
217- /**
218- * Disables the Sentry Webpack plugin on the server.
219- * See: https://github.com/getsentry/sentry-javascript/issues/10468#issuecomment-2004710692
220- */
221- disableServerWebpackPlugin : true ,
222- } ) ,
223- ) ,
224- ) ;
221+ export default getConfig ( ) ;
0 commit comments