Next.js Sentry Sourcemap size is too large

Viewed 973

i'm trying to use sourcemap feature of next.js for better debugging with sentry but when i build next app, it try to upload large sourcemap files to sentry.Is there anything wrong ?

enter image description here

Also my next.config.js configuration is like this.

const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const withSourceMaps = require('@zeit/next-source-maps')();

webpack: (config, { dev, isServer, buildId }) => {
    if (!isServer) {
      config.resolve.alias['@sentry/node'] = '@sentry/browser';
    }
    if (process.env.NODE_ENV === 'production') {
      config.plugins.push(
        new SentryWebpackPlugin({
          include: './app/.next',
          ignore: ['node_modules'],
          urlPrefix: '~/_next',
          release: buildId,
        }),
      );
    }

    return config;}
1 Answers
  1. npm remove @zeit/next-source-maps
  2. npm i next@latest

nextjs now has build in config to enable source maps in production https://nextjs.org/docs/advanced-features/source-maps I would also suggest to ignore *.css.map and other files not needed by sentry so do not upload them.

const SentryWebpackPlugin = require('@sentry/webpack-plugin');

...
module.exports = {
...
productionBrowserSourceMaps: process.env.NODE_ENV === 'production',
...
webpack: (config, { dev, isServer, buildId }) => {
    if (!isServer) {
      config.resolve.alias['@sentry/node'] = '@sentry/browser';
    }
    if (process.env.NODE_ENV === 'production') {
      config.plugins.push(
        new SentryWebpackPlugin({
          include: './app/.next',
          ignore: ['node_modules', '*.css.map'],
          stripPrefix: ['webpack://_N_E/'],
          urlPrefix: '~/_next',
          release: buildId,
        }),
      );
    }

    return config;
}
Related