diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index a606af5f339c..6092ee2ba3a2 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -630,32 +630,80 @@ export function getWebpackPluginOptions( ...defaultPluginOptions, ...userPluginOptions, errorHandler(err, invokeErr, compilation) { - // Hardcoded way to check for missing auth token until we have a better way of doing this. - if (err && err.message.includes('Authentication credentials were not provided.')) { - const warningPrefix = `${chalk.yellow('warn')} -`; - - let msg; - - if (process.env.VERCEL) { - msg = `To fix this, use Sentry's Vercel integration to automatically set the ${chalk.bold.cyan( - 'SENTRY_AUTH_TOKEN', - )} environment variable: https://vercel.com/integrations/sentry`; - } else { - msg = - 'You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/\n' + - `After generating a Sentry auth token, set it via the ${chalk.bold.cyan( + if (err) { + const errorMessagePrefix = `${chalk.red('error')} -`; + + // Hardcoded way to check for missing auth token until we have a better way of doing this. + if (err.message.includes('Authentication credentials were not provided.')) { + let msg; + + if (process.env.VERCEL) { + msg = `To fix this, use Sentry's Vercel integration to automatically set the ${chalk.bold.cyan( 'SENTRY_AUTH_TOKEN', - )} environment variable during the build.`; + )} environment variable: https://vercel.com/integrations/sentry`; + } else { + msg = + 'You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/\n' + + `After generating a Sentry auth token, set it via the ${chalk.bold.cyan( + 'SENTRY_AUTH_TOKEN', + )} environment variable during the build.`; + } + + // eslint-disable-next-line no-console + console.error( + `${errorMessagePrefix} ${chalk.bold( + 'No Sentry auth token configured.', + )} Source maps will not be uploaded.\n${msg}\n`, + ); + + return; } - // eslint-disable-next-line no-console - console.error( - `${warningPrefix} ${chalk.bold( - 'No Sentry auth token configured.', - )} Source maps will not be uploaded.\n${msg}\n`, - ); + // Hardcoded way to check for missing org slug until we have a better way of doing this. + if (err.message.includes('An organization slug is required')) { + let msg; + if (process.env.VERCEL) { + msg = `To fix this, use Sentry's Vercel integration to automatically set the ${chalk.bold.cyan( + 'SENTRY_ORG', + )} environment variable: https://vercel.com/integrations/sentry`; + } else { + msg = `To fix this, set the ${chalk.bold.cyan( + 'SENTRY_ORG', + )} environment variable to the to your organization slug during the build.`; + } + + // eslint-disable-next-line no-console + console.error( + `${errorMessagePrefix} ${chalk.bold( + 'No Sentry organization slug configured.', + )} Source maps will not be uploaded.\n${msg}\n`, + ); + + return; + } - return; + // Hardcoded way to check for missing project slug until we have a better way of doing this. + if (err.message.includes('A project slug is required')) { + let msg; + if (process.env.VERCEL) { + msg = `To fix this, use Sentry's Vercel integration to automatically set the ${chalk.bold.cyan( + 'SENTRY_PROJECT', + )} environment variable: https://vercel.com/integrations/sentry`; + } else { + msg = `To fix this, set the ${chalk.bold.cyan( + 'SENTRY_PROJECT', + )} environment variable to the name of your Sentry project during the build.`; + } + + // eslint-disable-next-line no-console + console.error( + `${errorMessagePrefix} ${chalk.bold( + 'No Sentry project slug configured.', + )} Source maps will not be uploaded.\n${msg}\n`, + ); + + return; + } } if (userPluginOptions.errorHandler) { @@ -679,6 +727,10 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions // with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users // try to build their apps. if (!SentryWebpackPlugin.cliBinaryExists()) { + // eslint-disable-next-line no-console + console.error( + `${chalk.red('error')} - ${chalk.bold('Sentry CLI binary not found.')} Source maps will not be uploaded.\n`, + ); return false; }