Skip to content
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

feat(nextjs): Add options to disable webpack plugin #3771

Merged

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Jun 30, 2021

Despite our strong encouragement, not everyone wants to use the SentryWebpackPlugin to upload sourcemaps. This PR introduces two new options, disableServerWebpackPlugin and disableClientWebpackPlugin, which can be used in next.config.js like this:

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

const moduleExports = {
  sentry: {
    disableServerWebpackPlugin: true,
    disableClientWebpackPlugin: true,
  },
};

// unnecessary if the webpack plugin is disabled for both server and client (in that case, can also safely 
// be omitted from the `withSentryConfig` call below)
const SentryWebpackPluginOptions = {
  // ...
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);

Setting either of these options does two things in the relevant (server or client) config:

  • prevents the SDK from forcing webpack.devtool to be source-map in production, and
  • prevents the SDK from adding an instance of SentryWebpackPlugin to the webpack config.

These changes are documented in getsentry/sentry-docs#3826.

Fixes #3674
Fixes #3513
Fixes #3553
Fixes #3737

@github-actions
Copy link
Contributor

github-actions bot commented Jun 30, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 21.39 KB (+0.01% 🔺)
@sentry/browser - Webpack 22.4 KB (0%)
@sentry/react - Webpack 22.44 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.89 KB (0%)

@@ -261,4 +261,43 @@ describe('Sentry webpack plugin config', () => {
it("merges default include and ignore/ignoreFile options with user's values", () => {
// do we even want to do this?
});

it('allows SentryWebpackPlugin to be turned off for client code (independent of server code)', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking some time to think about this, the tests for constructWebpackConfigFunction should just be a table test, where we pass in different permutations of the config and assert on the return value. We can do this in another PR though.

Base automatically changed from kmclb-pre-disable-plugin-option-cleanup to master June 30, 2021 20:09
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-add-option-to-disable-webpack-plugin branch from 54e8cd5 to f7460d9 Compare June 30, 2021 20:30
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: We need to add a task to add this new option to the docs.

@lobsterkatie
Copy link
Member Author

Reminder: We need to add a task to add this new option to the docs.

Precisely why It's still in draft mode! 🙂

NB: In draft form only because

@lobsterkatie lobsterkatie marked this pull request as ready for review June 30, 2021 23:02
@lobsterkatie lobsterkatie merged commit e06b502 into master Jun 30, 2021
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-add-option-to-disable-webpack-plugin branch June 30, 2021 23:05
lobsterkatie added a commit to getsentry/sentry-docs that referenced this pull request Jul 6, 2021
Add docs for the options introduced in getsentry/sentry-javascript#3771, which allow the user to disable the addition of `SentryWebpackPlugin` to server and client builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants