Skip to content

Commit

Permalink
update next config for better build
Browse files Browse the repository at this point in the history
this commit change means we no longer get the error:
  "Detected next.config.js, no exported configuration found.
  https://nextjs.org/docs/messages/empty-configuration"
  • Loading branch information
alishaevn committed Dec 15, 2023
1 parent b257bc6 commit 5bf1c93
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// This guard clause allows the app to still build in the event another exception handler will be used,
// or the sentry project hasn't been set up yet
if (!process.env.SENTRY_DSN) return

// This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
const { withSentryConfig } = require('@sentry/nextjs')
const SENTRY_DSN = process.env.SENTRY_DSN

const nextConfig = {
let nextConfig = {
output: 'standalone',
reactStrictMode: true,
swcMinify: true,
Expand All @@ -18,34 +15,43 @@ const nextConfig = {
// ref: https://nextjs.org/docs/pages/api-reference/next-config-js/eslint
ignoreDuringBuilds: true,
},
sentry: {
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
// for client-side builds. (This will be the default starting in
// `@sentry/nextjs` version 8.0.0.) See
// https://webpack.js.org/configuration/devtool/ and
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
// for more information.
hideSourceMaps: true,
},
}

const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, configFile, stripPrefix, urlPrefix, include, ignore

silent: true, // Suppresses all logs
project: process.env.SENTRY_PROJECT,
org: process.env.SENTRY_ORG,
authToken: process.env.SENTRY_AUTH_TOKEN,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
module.exports = nextConfig

// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(
nextConfig,
sentryWebpackPluginOptions
)
let sentryWebpackPluginOptions = {}
if (SENTRY_DSN) {
nextConfig = {
...nextConfig,
sentry: {
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
// for client-side builds. (This will be the default starting in
// `@sentry/nextjs` version 8.0.0.) See
// https://webpack.js.org/configuration/devtool/ and
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
// for more information.
hideSourceMaps: true,
},
}

sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, configFile, stripPrefix, urlPrefix, include, ignore

silent: true, // Suppresses all logs
project: process.env.SENTRY_PROJECT,
org: process.env.SENTRY_ORG,
authToken: process.env.SENTRY_AUTH_TOKEN,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
}

module.exports = withSentryConfig(
nextConfig,
sentryWebpackPluginOptions
)
}

1 comment on commit 5bf1c93

@vercel
Copy link

@vercel vercel bot commented on 5bf1c93 Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.