From 4b14427f360020f46bce0e401151bd5cf81bbc58 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 9 Jan 2022 13:52:57 +0530 Subject: [PATCH] disable sentry if next phase is PHASE_DEVELOPMENT_SERVER --- next.config.js | 70 ++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/next.config.js b/next.config.js index 1413dd1a9..056b654ad 100644 --- a/next.config.js +++ b/next.config.js @@ -4,6 +4,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({ const withWorkbox = require('@ente-io/next-with-workbox'); const { withSentryConfig } = require('@sentry/nextjs'); +const { PHASE_DEVELOPMENT_SERVER } = require('next/constants'); const { getGitSha, @@ -21,38 +22,39 @@ const GIT_SHA = getGitSha(); const IS_SENTRY_ENABLED = getIsSentryEnabled(); -module.exports = withSentryConfig( - withWorkbox( - withBundleAnalyzer({ - env: { - SENTRY_RELEASE: GIT_SHA, - }, - workbox: WORKBOX_CONFIG, +module.exports = (phase) => + withSentryConfig( + withWorkbox( + withBundleAnalyzer({ + env: { + SENTRY_RELEASE: GIT_SHA, + }, + workbox: WORKBOX_CONFIG, - headers() { - return [ - { - // Apply these headers to all routes in your application.... - source: ALL_ROUTES, - headers: convertToNextHeaderFormat({ - ...COOP_COEP_HEADERS, - ...WEB_SECURITY_HEADERS, - ...buildCSPHeader(CSP_DIRECTIVES), - }), - }, - ]; - }, - // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j - webpack: (config, { isServer }) => { - if (!isServer) { - config.resolve.fallback.fs = false; - } - return config; - }, - }) - ), - { - release: GIT_SHA, - dryRun: !IS_SENTRY_ENABLED, - } -); + headers() { + return [ + { + // Apply these headers to all routes in your application.... + source: ALL_ROUTES, + headers: convertToNextHeaderFormat({ + ...COOP_COEP_HEADERS, + ...WEB_SECURITY_HEADERS, + ...buildCSPHeader(CSP_DIRECTIVES), + }), + }, + ]; + }, + // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j + webpack: (config, { isServer }) => { + if (!isServer) { + config.resolve.fallback.fs = false; + } + return config; + }, + }) + ), + { + release: GIT_SHA, + dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED, + } + );