Source Maps

To enable readable stack traces in your Sentry errors, you need to upload your source maps to Sentry.

Readable Stack Traces

Uploading Source Maps in an Angular project

Automatic Setup

The easiest way to configure uploading source maps is by using the Sentry Wizard:

Copied
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

Manual Setup

If you want to configure source maps upload with Angular manually, follow the steps below.

Generating Source Maps

To generate source maps, you need to add the sourceMap option to your angular.json build configuration:

angular.json
Copied
{
  // ...
  "projects": {
    "my-app": {
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "sourceMap": {
                "scripts": true
              }
            }
          }
        }
      }
    }
  }
}

Uploading Source Maps

To upload your Angular

projectRepresents your service in Sentry and allows you to scope events to a distinct application.
's source maps to Sentry, we recommend one of these options:

  • Angular CLI and Sentry webpack plugin
    Use the Angular CLI, a custom Angular builder and the Sentry webpack plugin to set releases and upload source maps automatically when running ng build.
  • Nx Angular CLI and Sentry webpack plugin
    If you're using Nx, use @nx/angular CLI and the Sentry webpack plugin to set releases and upload source maps automatically when running nx build.
  • Sentry CLI
    Upload source maps manually using the Sentry CLI.

Take a look at this guide for further options to upload source maps.

Additional Resources

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").