Sitelet https://github.com/getsentry/sentry-javascript/issues/3674
Skip to content

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

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 }
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions