File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
packages/nextjs/src/config Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { dropUndefinedKeys, logger } from '@sentry/utils';
3
3
import * as SentryWebpackPlugin from '@sentry/webpack-plugin' ;
4
4
import * as fs from 'fs' ;
5
5
import * as path from 'path' ;
6
- import { DefinePlugin } from 'webpack' ;
6
+ import { DefinePlugin , WebpackPluginInstance } from 'webpack' ;
7
7
8
8
import {
9
9
BuildContext ,
@@ -310,3 +310,19 @@ export function getWebpackPluginOptions(
310
310
311
311
return { ...defaultPluginOptions , ...userPluginOptions } ;
312
312
}
313
+
314
+ /**
315
+ * Helper function to search through the webpack config object's `plugins` array for a particular plugin.
316
+ *
317
+ * Note: Though it's used only once here, this is abstracted into a separate function because it's helpful for tests.
318
+ *
319
+ * @param webpackConfig The webpack config in object form
320
+ * @param pluginName The name of the desired plugin
321
+ * @returns The instance of the plugin, if it's included in `plugins`, or undefined if it's not
322
+ */
323
+ export function findWebpackPlugin (
324
+ webpackConfig : WebpackConfigObject ,
325
+ pluginName : string ,
326
+ ) : WebpackPluginInstance | SentryWebpackPlugin | undefined {
327
+ return webpackConfig . plugins ?. find ( plugin => plugin . constructor . name === pluginName ) ;
328
+ }
You can’t perform that action at this time.
0 commit comments