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 a Remix Project

If you installed the Remix SDK with the Sentry Wizard, source maps upload was already configured for you. Whenever you run the build script in your package.json source maps will be uploaded automatically.

If you installed the SDK manually or the wizard failed, follow the steps below to manually configure source maps upload.

Configure Source Maps Upload

The Sentry Remix SDK provides a script to automatically create a release and upload source maps after you've built your project. Under the hood, it uses the Sentry CLI.

This script requires setting an auth token, which can either be done through a .sentryclirc file in the root of your project or through environment variables:

.sentryclirc
Copied
# Do not commit this file to your repository!
# Sentry Auth tokens should be treated as a secret.
[auth]
token=sntrys_YOUR_TOKEN_HERE

Next, adjust your package.json's production build command to include the sentry-upload-sourcemaps script:

package.json
Copied
{
  "scripts": {
    "build": "remix build --sourcemap && sentry-upload-sourcemaps --org example-org --project example-project"
  }
}

Alternatively, you can run the script directly with npx:

Copied
npx sentry-upload-sourcemaps --org example-org --project example-project

# For usage details run
npx sentry-upload-sourcemaps --help

Remove Remix Source Maps

Remix validly discourages hosting source maps in production. After uploading the maps to Sentry, we suggest you delete the .map files. The sentry-upload-sourcemaps script will automatically try to delete all generated source maps after they're uploaded (unless the --deleteAfterUpload flag is provided).

If you want to be extra sure they're deleted, you can use the following shell script:

Copied
find ./public/build -type f -name '*.map' -delete
find ./build -type f -name '*.map' -delete

Please note that these commands might vary for the operating system or shell you use.

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").