Skip to content

Option to disable source-map upload on @sentry/next #3674

Closed
@Utwo

Description

@Utwo

Please add an option to disable source-maps upload to @sentry/nextjs package.
Because generating the sourcemaps and uploading them to Sentry takes quite some time, I only want to use sourcemaps when deploying to production. So for live preview deploys I would like to use the @sentry/nextjs package without sourcemap support.

As a quick fix I managed to get it working with this script in next.config.js

const removeSentryPluginOnDev = (config) => {
    if (process.env.NEXT_PUBLIC_APP_ENV === 'production') {
      return config
    }

    const newWebpackExport = (webpackConfig, options) => {
      const newConfig = config.webpack(webpackConfig, options)
      const sentryPlugin = newConfig.plugins.pop()
      if (sentryPlugin.options.configFile !== 'sentry.properties') {
        throw Error('Seems like the SentryPlugin was not removed.')
      }
      return newConfig
    }

    return { ...config, productionBrowserSourceMaps: false, webpack: newWebpackExport }
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions