diff --git a/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.mdx b/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.mdx new file mode 100644 index 0000000000000..987a227812f4f --- /dev/null +++ b/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.mdx @@ -0,0 +1,11 @@ +```javascript +module.exports = { + output: { + // Make maps auto-detectable by sentry-cli + filename: "[name].js", + sourceMapFilename: "[name].js.map", + // Other `output` configuration + }, + // Other configuration +}; +``` diff --git a/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.nextjs.mdx b/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.nextjs.mdx new file mode 100644 index 0000000000000..76c5c19f0404f --- /dev/null +++ b/src/includes/configuration/sourcemaps/tools/webpack/advanced-usage/javascript.nextjs.mdx @@ -0,0 +1,26 @@ +```javascript {filename:next.config.js} +const { withSentryConfig } = require("@sentry/nextjs"); + +const moduleExports = { + webpack: (config, options) => { + devtool = 'source-map', + config.output = { + ...config.output, + // Make maps auto-detectable by sentry-cli + filename: "[name].js", + sourceMapFilename: "[name].js.map", + }; + return config; + }, + productionBrowserSourceMaps: true, + // 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). diff --git a/src/platforms/javascript/common/sourcemaps/tools/webpack.mdx b/src/platforms/javascript/common/sourcemaps/tools/webpack.mdx index aa9b02f12b929..826edafa4cb95 100644 --- a/src/platforms/javascript/common/sourcemaps/tools/webpack.mdx +++ b/src/platforms/javascript/common/sourcemaps/tools/webpack.mdx @@ -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 -}; -``` + 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.