@@ -626,7 +626,45 @@ export function getWebpackPluginOptions(
626626
627627 checkWebpackPluginOverrides ( defaultPluginOptions , userPluginOptions ) ;
628628
629- return { ...defaultPluginOptions , ...userPluginOptions } ;
629+ return {
630+ ...defaultPluginOptions ,
631+ ...userPluginOptions ,
632+ errorHandler ( err , invokeErr , compilation ) {
633+ // Hardcoded way to check for missing auth token until we have a better way of doing this.
634+ if ( err && err . message . includes ( 'Authentication credentials were not provided.' ) ) {
635+ const warningPrefix = `${ chalk . yellow ( 'warn' ) } -` ;
636+
637+ let msg ;
638+
639+ if ( process . env . VERCEL ) {
640+ msg = `To fix this, use Sentry's Vercel integration to automatically set the ${ chalk . bold . cyan (
641+ 'SENTRY_AUTH_TOKEN' ,
642+ ) } environment variable: https://vercel.com/integrations/sentry`;
643+ } else {
644+ msg =
645+ 'You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/\n' +
646+ `After generating a Sentry auth token, set it via the ${ chalk . bold . cyan (
647+ 'SENTRY_AUTH_TOKEN' ,
648+ ) } environment variable during the build.`;
649+ }
650+
651+ // eslint-disable-next-line no-console
652+ console . error (
653+ `${ warningPrefix } ${ chalk . bold (
654+ 'No Sentry auth token configured.' ,
655+ ) } Source maps will not be uploaded.\n${ msg } \n`,
656+ ) ;
657+
658+ return ;
659+ }
660+
661+ if ( userPluginOptions . errorHandler ) {
662+ return userPluginOptions . errorHandler ( err , invokeErr , compilation ) ;
663+ }
664+
665+ return invokeErr ( ) ;
666+ } ,
667+ } ;
630668}
631669
632670/** Check various conditions to decide if we should run the plugin */
0 commit comments