Webpack
This guide assumes you are using a Sentry SDK on version 7.47.0
or higher.
If you are on an older version and you want to upload source maps we recommend upgrading your SDK to the newest version.
You can use the Sentry webpack plugin to automatically create releases and upload source maps to Sentry when bundling your app.
Automatic Setup
The easiest way to configure uploading source maps with webpack is by using the Sentry Wizard:
npx @sentry/wizard@latest -i sourcemaps
The wizard will guide you through the following steps:
- Logging into Sentry and selecting a projectRepresents your service in Sentry and allows you to scope events to a distinct application.
- Installing the necessary Sentry packages
- Configuring your build tool to generate and upload source maps
- Configuring your CI to upload source maps
If you want to configure source maps upload with webpack manually, follow the steps below.
Manual Setup
Install the Sentry webpack plugin:
npm install @sentry/webpack-plugin --save-dev
Configuration
To upload source maps you have to configure an auth
authToken
option, with a SENTRY_AUTH_TOKEN
environment variable, or with an .env.sentry-build-plugin
file in the working directory when building your Learn more about configuring the plugin in our Sentry webpack plugin documentation.
.env.sentry-build-plugin
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
And the following webpack config:
webpack.config.js
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
module.exports = {
// ... other config above ...
devtool: "source-map", // Source map generation must be turned on
plugins: [
sentryWebpackPlugin({
org: "example-org",
project: "example-project",
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
};
The Sentry webpack plugin doesn't upload source maps in watch-mode/development-mode. We recommend running a production build to test your configuration.
If you use SourceMapDevToolPlugin for more fine-grained control of source map generation, turn off noSources
so Sentry can display proper source code context in event stack traces.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/browser
- Version:
- 7.72.0
- Repository:
- https://github.com/getsentry/sentry-javascript