Skip to content

Commit 19ecbe1

Browse files
fix(nextjs): Update code sample in Advanced Usage of Webpack (#3677)
The advanced usage of Webpack was valid in a prior version of the SDK. This PR updates that code sample, besides removing some comments to reduce noise. If a user wants to read that noise or just learn more about it, a link to the `manual-setup` page has been included.
1 parent 282016d commit 19ecbe1

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```javascript
2+
module.exports = {
3+
output: {
4+
// Make maps auto-detectable by sentry-cli
5+
filename: "[name].js",
6+
sourceMapFilename: "[name].js.map",
7+
// Other `output` configuration
8+
},
9+
// Other configuration
10+
};
11+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```javascript {filename:next.config.js}
2+
const { withSentryConfig } = require("@sentry/nextjs");
3+
4+
const moduleExports = {
5+
webpack: (config, options) => {
6+
devtool = 'source-map',
7+
config.output = {
8+
...config.output,
9+
// Make maps auto-detectable by sentry-cli
10+
filename: "[name].js",
11+
sourceMapFilename: "[name].js.map",
12+
};
13+
return config;
14+
},
15+
productionBrowserSourceMaps: true,
16+
// Other nextjs configuration
17+
};
18+
19+
const SentryWebpackPluginOptions = {
20+
// Additional config options for the Sentry Webpack plugin.
21+
};
22+
23+
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
24+
```
25+
26+
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).

src/platforms/javascript/common/sourcemaps/tools/webpack.mdx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,7 @@ Set up the `SentryWebpackPlugin` as the last running plugin, otherwise, the resu
7777

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

80-
```javascript
81-
module.exports = {
82-
output: {
83-
path: path.join(__dirname, "dist"),
84-
filename: "[name].js",
85-
sourceMapFilename: "[name].js.map",
86-
},
87-
// other configuration
88-
};
89-
```
80+
<PlatformContent includePath="configuration/sourcemaps/tools/webpack/advanced-usage" />
9081

9182
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.
9283

0 commit comments

Comments
 (0)