Skip to content

fix(nextjs): Fix incomplete merging of user config with Sentry config #3434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/nextjs/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ export function withSentryConfig(
}

return {
experimental: { plugins: true },
...providedExports,
experimental: { ...(providedExports.experimental || {}), plugins: true },
plugins: [...(providedExports.plugins || []), '@sentry/next-plugin-sentry'],
productionBrowserSourceMaps: true,
webpack: (config, { dev }) => {
if (!dev) {
webpack: (originalConfig, options) => {
let config = originalConfig;

if (typeof providedExports.webpack === 'function') {
config = providedExports.webpack(originalConfig, options);
}

if (!options.dev) {
// Ensure quality source maps in production. (Source maps aren't uploaded in dev, and besides, Next doesn't let
// you change this is dev even if you want to - see
// https://github.com/vercel/next.js/blob/master/errors/improper-devtool.md.)
Expand All @@ -86,11 +93,12 @@ export function withSentryConfig(
config.plugins.push(
// TODO it's not clear how to do this better, but there *must* be a better way
new ((SentryWebpackPlugin as unknown) as typeof defaultWebpackPlugin)({
dryRun: dev,
dryRun: options.dev,
...defaultWebpackPluginOptions,
...providedWebpackPluginOptions,
}),
);

return config;
},
};
Expand Down