|
1 |
| -// This guard clause allows the app to still build in the event another exception handler will be used, |
2 |
| -// or the sentry project hasn't been set up yet |
3 |
| -if (!process.env.SENTRY_DSN) return |
4 |
| - |
5 | 1 | // This file sets a custom webpack configuration to use your Next.js app
|
6 | 2 | // with Sentry.
|
7 | 3 | // https://nextjs.org/docs/api-reference/next.config.js/introduction
|
8 | 4 | // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
9 | 5 | const { withSentryConfig } = require('@sentry/nextjs')
|
| 6 | +const SENTRY_DSN = process.env.SENTRY_DSN |
10 | 7 |
|
11 |
| -const nextConfig = { |
| 8 | +let nextConfig = { |
12 | 9 | output: 'standalone',
|
13 | 10 | reactStrictMode: true,
|
14 | 11 | swcMinify: true,
|
15 | 12 | eslint: {
|
16 |
| - dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds |
17 |
| - }, |
18 |
| - sentry: { |
19 |
| - // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool` |
20 |
| - // for client-side builds. (This will be the default starting in |
21 |
| - // `@sentry/nextjs` version 8.0.0.) See |
22 |
| - // https://webpack.js.org/configuration/devtool/ and |
23 |
| - // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map |
24 |
| - // for more information. |
25 |
| - hideSourceMaps: true, |
| 13 | + // Warning: This allows production builds to successfully complete even if |
| 14 | + // your project has ESLint errors. |
| 15 | + // ref: https://nextjs.org/docs/pages/api-reference/next-config-js/eslint |
| 16 | + ignoreDuringBuilds: true, |
26 | 17 | },
|
27 | 18 | }
|
28 | 19 |
|
29 |
| -const sentryWebpackPluginOptions = { |
30 |
| - // Additional config options for the Sentry Webpack plugin. Keep in mind that |
31 |
| - // the following options are set automatically, and overriding them is not |
32 |
| - // recommended: |
33 |
| - // release, url, configFile, stripPrefix, urlPrefix, include, ignore |
34 |
| - |
35 |
| - silent: true, // Suppresses all logs |
36 |
| - project: process.env.SENTRY_PROJECT, |
37 |
| - org: process.env.SENTRY_ORG, |
38 |
| - authToken: process.env.SENTRY_AUTH_TOKEN, |
39 |
| - // For all available options, see: |
40 |
| - // https://github.com/getsentry/sentry-webpack-plugin#options. |
41 |
| -} |
| 20 | +module.exports = nextConfig |
42 | 21 |
|
43 | 22 | // Make sure adding Sentry options is the last code to run before exporting, to
|
44 | 23 | // ensure that your source maps include changes from all other Webpack plugins
|
45 |
| -module.exports = withSentryConfig( |
46 |
| - nextConfig, |
47 |
| - sentryWebpackPluginOptions |
48 |
| -) |
| 24 | +let sentryWebpackPluginOptions = {} |
| 25 | +if (SENTRY_DSN) { |
| 26 | + nextConfig = { |
| 27 | + ...nextConfig, |
| 28 | + sentry: { |
| 29 | + // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool` |
| 30 | + // for client-side builds. (This will be the default starting in |
| 31 | + // `@sentry/nextjs` version 8.0.0.) See |
| 32 | + // https://webpack.js.org/configuration/devtool/ and |
| 33 | + // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map |
| 34 | + // for more information. |
| 35 | + hideSourceMaps: true, |
| 36 | + }, |
| 37 | + } |
| 38 | + |
| 39 | + sentryWebpackPluginOptions = { |
| 40 | + // Additional config options for the Sentry Webpack plugin. Keep in mind that |
| 41 | + // the following options are set automatically, and overriding them is not |
| 42 | + // recommended: |
| 43 | + // release, url, configFile, stripPrefix, urlPrefix, include, ignore |
| 44 | + |
| 45 | + silent: true, // Suppresses all logs |
| 46 | + project: process.env.SENTRY_PROJECT, |
| 47 | + org: process.env.SENTRY_ORG, |
| 48 | + authToken: process.env.SENTRY_AUTH_TOKEN, |
| 49 | + // For all available options, see: |
| 50 | + // https://github.com/getsentry/sentry-webpack-plugin#options |
| 51 | + } |
| 52 | + |
| 53 | + module.exports = withSentryConfig( |
| 54 | + nextConfig, |
| 55 | + sentryWebpackPluginOptions |
| 56 | + ) |
| 57 | +} |
0 commit comments