Skip to content

How to use with new Sentry integration #50

Open
@chris-erickson

Description

@chris-erickson

Sentry has a great integration for Next.js but it assumes you're using a typical config. Is this something that's possible to make work with next-compose-plugins?

Here's a sample config they generate as a starting point:

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

const { withSentryConfig } = require('@sentry/nextjs');

const moduleExports = {
  // Your existing module.exports
};

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, org, project, authToken, configFile, stripPrefix,
  //   urlPrefix, include, ignore
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
};

// 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(moduleExports, SentryWebpackPluginOptions);

And here's a pretty basic implementation of next-compose-plugins (I'm not well-versed in this so just wrapping this around the finalized next-compose-plugins caused webpack 4 instead of 5 to be used, etc.

const withPlugins = require('next-compose-plugins');
const nextImages = require('next-images');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === '1',
});

const nextConfig = {
  future: {
    webpack5: true,
  },
  images: {
    domains: ['example.com'],
  },
};

module.exports = withPlugins(
  [
    [
      nextImages,
      {
        esModule: true,
      },
    ],
    [withBundleAnalyzer],
  ],
  nextConfig
);

Any pointers are appreciated — I'll post a working setup once I get there 😬

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions