File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
1
import type { GLOBAL_OBJ } from '@sentry/utils' ;
2
2
import type { SentryCliPluginOptions } from '@sentry/webpack-plugin' ;
3
- import type { WebpackPluginInstance } from 'webpack' ;
3
+ import type { DefinePlugin , WebpackPluginInstance } from 'webpack' ;
4
4
5
5
export type SentryWebpackPluginOptions = SentryCliPluginOptions ;
6
6
export type SentryWebpackPlugin = WebpackPluginInstance & { options : SentryWebpackPluginOptions } ;
@@ -128,6 +128,11 @@ export type UserSentryOptions = {
128
128
* NOTE: This feature only works with Next.js 11+
129
129
*/
130
130
tunnelRoute ?: string ;
131
+
132
+ /**
133
+ * Tree shakes Sentry SDK logger statements from the bundle.
134
+ */
135
+ disableLogger ?: boolean ;
131
136
} ;
132
137
133
138
export type NextConfigFunction = ( phase : string , defaults : { defaultConfig : NextConfigObject } ) => NextConfigObject ;
@@ -167,7 +172,10 @@ export type BuildContext = {
167
172
dir : string ;
168
173
// eslint-disable-next-line @typescript-eslint/no-explicit-any
169
174
config : any ;
170
- webpack : { version : string } ;
175
+ webpack : {
176
+ version : string ;
177
+ DefinePlugin : typeof DefinePlugin ;
178
+ } ;
171
179
// eslint-disable-next-line @typescript-eslint/no-explicit-any
172
180
defaultLoaders : any ;
173
181
totalPages : number ;
Original file line number Diff line number Diff line change @@ -296,6 +296,15 @@ export function constructWebpackConfigFunction(
296
296
}
297
297
}
298
298
299
+ if ( userSentryOptions . disableLogger ) {
300
+ newConfig . plugins = newConfig . plugins || [ ] ;
301
+ newConfig . plugins . push (
302
+ new buildContext . webpack . DefinePlugin ( {
303
+ __SENTRY_DEBUG__ : false ,
304
+ } ) ,
305
+ ) ;
306
+ }
307
+
299
308
return newConfig ;
300
309
} ;
301
310
}
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ export function getBuildContext(
99
99
distDir : '.next' ,
100
100
...materializedNextConfig ,
101
101
} as NextConfigObject ,
102
- webpack : { version : webpackVersion } ,
102
+ webpack : { version : webpackVersion , DefinePlugin : class { } as any } ,
103
103
defaultLoaders : true ,
104
104
totalPages : 2 ,
105
105
isServer : buildTarget === 'server' || buildTarget === 'edge' ,
You can’t perform that action at this time.
0 commit comments