From e2921c3126dbd749460c0b9584bae65539e4644e Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Fri, 18 Nov 2022 14:23:14 +0000 Subject: [PATCH] Techdebt/improve sentry config (#5585) * Fix console errors during build * Create source maps for production --- apps/web/next.config.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index cec95140c9..5254ae6af8 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -80,6 +80,7 @@ plugins.push(withAxiom); /** @type {import("next").NextConfig} */ const nextConfig = { i18n, + productionBrowserSourceMaps: true, /* We already do type check on GH actions */ typescript: { ignoreBuildErrors: !!process.env.CI, @@ -88,10 +89,8 @@ const nextConfig = { eslint: { ignoreDuringBuilds: !!process.env.CI, }, - experimental: { - images: { - unoptimized: true, - }, + images: { + unoptimized: true, }, webpack: (config) => { config.plugins.push( @@ -230,11 +229,6 @@ const nextConfig = { return redirects; }, - sentry: { - hideSourceMaps: true, - // Prevents Sentry from running on this Edge function, where Sentry doesn't work yet (build whould crash the api route). - excludeServerRoutes: [/\/api\/social\/og\/image\/?/], - }, }; const sentryWebpackPluginOptions = { @@ -243,6 +237,14 @@ const sentryWebpackPluginOptions = { const moduleExports = () => plugins.reduce((acc, next) => next(acc), nextConfig); +if (process.env.NEXT_PUBLIC_SENTRY_DSN) { + nextConfig.sentry = { + hideSourceMaps: true, + // Prevents Sentry from running on this Edge function, where Sentry doesn't work yet (build whould crash the api route). + excludeServerRoutes: [/\/api\/social\/og\/image\/?/], + }; +} + // Sentry should be the last thing to export to catch everything right module.exports = process.env.NEXT_PUBLIC_SENTRY_DSN ? withSentryConfig(moduleExports, sentryWebpackPluginOptions)