1- /* eslint-disable @typescript-eslint/no-var-requires */
1+ import type { NextConfig } from "next" ;
2+ import FRAMER_PATHS from "./framer-rewrites" ;
3+ import getRedirects from "./redirects" ;
24
35const ContentSecurityPolicy = `
46 default-src 'self';
@@ -37,13 +39,7 @@ const securityHeaders = [
3739 } ,
3840] ;
3941
40- const redirects = require ( "./redirects" ) ;
41- const FRAMER_PATHS = require ( "./framer-rewrites" ) ;
42-
43- /**
44- * @returns {import('next').RemotePattern[] }
45- */
46- function determineIpfsGateways ( ) {
42+ function determineIpfsGateways ( ) : NextConfig [ "images" ] {
4743 // add the clientId ipfs gateways
4844 const remotePatterns = [ ] ;
4945 if ( process . env . API_ROUTES_CLIENT_ID ) {
@@ -84,23 +80,48 @@ function determineIpfsGateways() {
8480 return remotePatterns ;
8581}
8682
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- } ,
83+ const SENTRY_OPTIONS : SentryBuildOptions = {
84+ // For all available options, see:
85+ // https://github.com/getsentry/sentry-webpack-plugin#options
86+
87+ org : "thirdweb-dev" ,
88+ project : "dashboard" ,
89+ // An auth token is required for uploading source maps.
90+ authToken : process . env . SENTRY_AUTH_TOKEN ,
91+ // Suppresses source map uploading logs during build
92+ silent : true ,
93+ // For all available options, see:
94+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
95+
96+ // Upload a larger set of source maps for prettier stack traces (increases build time)
97+ widenClientFileUpload : true ,
98+
99+ // Transpiles SDK to be compatible with IE11 (increases bundle size)
100+ transpileClientSDK : false ,
101+
102+ // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
103+ tunnelRoute : "/err" ,
104+
105+ // Hides source maps from generated client bundles
106+ hideSourceMaps : true ,
107+
108+ // Automatically tree-shake Sentry logger statements to reduce bundle size
109+ disableLogger : true ,
110+
111+ // Enables automatic instrumentation of Vercel Cron Monitors.
112+ // See the following for more information:
113+ // https://docs.sentry.io/product/crons/
114+ // https://vercel.com/docs/cron-jobs
115+ automaticVercelMonitors : false ,
116+
117+ /**
118+ * Disables the Sentry Webpack plugin on the server.
119+ * See: https://github.com/getsentry/sentry-javascript/issues/10468#issuecomment-2004710692
120+ */
121+ disableServerWebpackPlugin : true ,
122+ } ;
123+
124+ const baseNextConfig : NextConfig = {
104125 async headers ( ) {
105126 return [
106127 {
@@ -117,7 +138,7 @@ const moduleExports = {
117138 ] ;
118139 } ,
119140 async redirects ( ) {
120- return redirects ( ) ;
141+ return getRedirects ( ) ;
121142 } ,
122143 async rewrites ( ) {
123144 return [
@@ -151,74 +172,59 @@ const moduleExports = {
151172 ...determineIpfsGateways ( ) ,
152173 ] ,
153174 } ,
154- reactStrictMode : true ,
155- experimental : {
156- scrollRestoration : true ,
157- webpackBuildWorker : true ,
158- serverSourceMaps : false ,
159- } ,
160- cacheMaxMemorySize : 0 ,
161175 compiler : {
162176 emotion : true ,
163177 } ,
164- productionBrowserSourceMaps : false ,
178+ reactStrictMode : true ,
165179} ;
166180
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 ,
181+ function getConfig ( ) : NextConfig {
182+ if ( process . env . NODE_ENV === "production" ) {
183+ // eslint-disable-next-line @typescript-eslint/no-var-requires
184+ const withBundleAnalyzer = require ( "@next/bundle-analyzer" ) ( {
185+ enabled : process . env . ANALYZE === "true" ,
186+ } ) ;
187+ // eslint-disable-next-line @typescript-eslint/no-var-requires
188+ const { withPlausibleProxy } = require ( "next-plausible" ) ;
189+ // eslint-disable-next-line @typescript-eslint/no-var-requires
190+ const { withSentryConfig } = require ( "@sentry/nextjs" ) ;
191+ return withBundleAnalyzer (
192+ withPlausibleProxy ( {
193+ customDomain : "https://pl.thirdweb.com" ,
194+ scriptName : "pl" ,
195+ } ) (
196+ withSentryConfig (
197+ {
198+ ...baseNextConfig ,
199+ experimental : {
200+ webpackBuildWorker : true ,
201+ serverSourceMaps : false ,
202+ } ,
203+ webpack : ( config , { dev } ) => {
204+ if ( config . cache && ! dev ) {
205+ config . cache = Object . freeze ( {
206+ type : "filesystem" ,
207+ maxMemoryGenerations : 0 ,
208+ } ) ;
209+ }
210+ config . externals . push ( "pino-pretty" ) ;
211+ config . module = {
212+ ...config . module ,
213+ exprContextCritical : false ,
214+ } ;
215+ // Important: return the modified config
216+ return config ;
217+ } ,
218+ productionBrowserSourceMaps : false ,
219+ cacheMaxMemorySize : 0 ,
220+ } ,
221+ SENTRY_OPTIONS ,
222+ ) ,
223+ ) ,
224+ ) ;
225+ }
226+ // otherwise return the base
227+ return baseNextConfig ;
228+ }
216229
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- ) ;
230+ export default getConfig ( ) ;
0 commit comments