disable sentry if next phase is PHASE_DEVELOPMENT_SERVER

This commit is contained in:
Abhinav 2022-01-09 13:52:57 +05:30
parent 4cdc93e345
commit 4b14427f36

View file

@ -4,6 +4,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
const withWorkbox = require('@ente-io/next-with-workbox'); const withWorkbox = require('@ente-io/next-with-workbox');
const { withSentryConfig } = require('@sentry/nextjs'); const { withSentryConfig } = require('@sentry/nextjs');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const { const {
getGitSha, getGitSha,
@ -21,38 +22,39 @@ const GIT_SHA = getGitSha();
const IS_SENTRY_ENABLED = getIsSentryEnabled(); const IS_SENTRY_ENABLED = getIsSentryEnabled();
module.exports = withSentryConfig( module.exports = (phase) =>
withWorkbox( withSentryConfig(
withBundleAnalyzer({ withWorkbox(
env: { withBundleAnalyzer({
SENTRY_RELEASE: GIT_SHA, env: {
}, SENTRY_RELEASE: GIT_SHA,
workbox: WORKBOX_CONFIG, },
workbox: WORKBOX_CONFIG,
headers() { headers() {
return [ return [
{ {
// Apply these headers to all routes in your application.... // Apply these headers to all routes in your application....
source: ALL_ROUTES, source: ALL_ROUTES,
headers: convertToNextHeaderFormat({ headers: convertToNextHeaderFormat({
...COOP_COEP_HEADERS, ...COOP_COEP_HEADERS,
...WEB_SECURITY_HEADERS, ...WEB_SECURITY_HEADERS,
...buildCSPHeader(CSP_DIRECTIVES), ...buildCSPHeader(CSP_DIRECTIVES),
}), }),
}, },
]; ];
}, },
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => { webpack: (config, { isServer }) => {
if (!isServer) { if (!isServer) {
config.resolve.fallback.fs = false; config.resolve.fallback.fs = false;
} }
return config; return config;
}, },
}) })
), ),
{ {
release: GIT_SHA, release: GIT_SHA,
dryRun: !IS_SENTRY_ENABLED, dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,
} }
); );