Parcourir la source

disable sentry if next phase is PHASE_DEVELOPMENT_SERVER

Abhinav il y a 3 ans
Parent
commit
4b14427f36
1 fichiers modifiés avec 36 ajouts et 34 suppressions
  1. 36 34
      next.config.js

+ 36 - 34
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,
+        }
+    );