Webpack
You can use the Sentry Webpack plugin to automatically create releases and upload source maps to Sentry when bundling your app.
This guide for the Sentry Webpack plugin is for version 2.x
of the plugin.
If you are using version 1.x
of @sentry/webpack-plugin
please see the migration guide on how to update:
https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/MIGRATION.md
Installation
Copied
npm install @sentry/webpack-plugin --save-dev
Configuration
Learn more about configuring the plugin in our Sentry Webpack Plugin documentation.
Example:
webpack.config.js
Copied
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",
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
// Specify the directory containing build artifacts
assets: "./**",
// Don't upload the source maps of dependencies
ignore: ["./node_modules/**"],
},
// Helps troubleshooting - set to false to make plugin less noisy
debug: true,
// Use the following option if you're on an SDK version lower than 7.47.0:
// release: {
// uploadLegacySourcemaps: {
// include: ".",
// ignore: ["node_modules"],
// },
// },
// Optionally uncomment the line below to override automatic release name detection
// release: process.env.RELEASE,
}),
],
};
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.
Help improve this content
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").
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/react
- Version:
- 7.53.1
- Repository:
- https://github.com/getsentry/sentry-javascript