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

fix(nextjs): Update code sample in Advanced Usage of Webpack #3677

Merged
merged 5 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```javascript
lobsterkatie marked this conversation as resolved.
Show resolved Hide resolved
module.exports = {
lobsterkatie marked this conversation as resolved.
Show resolved Hide resolved
output: {
// Make maps auto-detectable by sentry-cli
filename: "[name].js",
sourceMapFilename: "[name].js.map",
// Other `output` configuration
},
// Other configuration
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");

const moduleExports = {
webpack: (config, options) => {
devtool = 'source-map',
lobsterkatie marked this conversation as resolved.
Show resolved Hide resolved
config.output = {
...config.output,
// Make maps auto-detectable by sentry-cli
filename: "[name].js",
sourceMapFilename: "[name].js.map",
};
return config;
},
productionBrowserSourceMaps: true,
lobsterkatie marked this conversation as resolved.
Show resolved Hide resolved
// Other nextjs configuration
};

const SentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin.
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
```

Learn more about the Webpack usage for the Next.js SDK in [Extend Default Webpack Usage](/platforms/javascript/guides/nextjs/manual-setup/#extend-default-webpack-usage).
11 changes: 1 addition & 10 deletions src/platforms/javascript/common/sourcemaps/tools/webpack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,7 @@ Set up the `SentryWebpackPlugin` as the last running plugin, otherwise, the resu

If you prefer to upload source maps manually, configure Webpack to output source maps:

```javascript
module.exports = {
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
sourceMapFilename: "[name].js.map",
},
// other configuration
};
```
<PlatformContent includePath="configuration/sourcemaps/tools/webpack/advanced-usage" />
lobsterkatie marked this conversation as resolved.
Show resolved Hide resolved

If you use [SourceMapDevToolPlugin](https://webpack.js.org/plugins/source-map-dev-tool-plugin) for more fine-grained control of source map generation, turn off `noSources` so Sentry can display proper source code context in event stack traces.

Expand Down