Upload source maps to Sentry for readable production stack traces using build plugins or sentry-cli. Use when stack traces are minified, setting up CI source map uploads, or configuring build tool plugins.
Upload source maps to Sentry so minified production stack traces resolve to readable original source code.
release identifier (see sentry/setup)SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECTsourcemap: "hidden" in build confignpm install @sentry/vite-plugin --save-dev
// vite.config.js
import { defineConfig } from "vite";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
build: {
sourcemap: "hidden",
},
plugins: [
// MUST be the LAST plugin
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
filesToDeleteAfterUpload: ["./**/*.map"],
},
}),
],
});
npm install @sentry/webpack-plugin --save-dev
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
module.exports = {
devtool: "source-map",
plugins: [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
};
Same pattern — install @sentry/rollup-plugin or @sentry/esbuild-plugin and add to plugins array with org, project, authToken.
For CI pipelines or unsupported build tools:
npm install @sentry/cli --save-dev
export SENTRY_AUTH_TOKEN="sntrys_..."
export SENTRY_ORG="my-org"
export SENTRY_PROJECT="my-project"
# Inject Debug IDs into source files and maps
sentry-cli sourcemaps inject ./dist
# Upload source maps
sentry-cli sourcemaps upload ./dist
Full release flow:
VERSION=$(sentry-cli releases propose-version)
sentry-cli releases new "$VERSION"
sentry-cli releases set-commits "$VERSION" --auto
sentry-cli sourcemaps inject ./dist
sentry-cli sourcemaps upload --release="$VERSION" ./dist
sentry-cli releases finalize "$VERSION"
sentry-cli deploys new --release="$VERSION" -e production
Auto-detects your build tool and configures everything:
npx @sentry/wizard@latest -i sourcemaps
Create a token at sentry.io/settings/auth-tokens/ with:
Store as SENTRY_AUTH_TOKEN in CI secrets. Build plugins also accept a .env.sentry-build-plugin file (never commit this).
Source maps contain your original source code. After uploading:
.map files from your deployment (filesToDeleteAfterUpload)sourcemap: "hidden" to avoid //# sourceMappingURL referenceshttps://your-app.com/assets/main.js.map returns 404release in Sentry.init() must exactly match the release used during uploadsentry-cli sourcemaps inject before uploadwithSentryConfig() handles source map uploads automatically| Symptom | Fix |
|---|---|
| Minified stack traces | Verify source maps are uploaded (Settings → Source Maps) |
| "Authentication failed" | Regenerate token at sentry.io/settings/auth-tokens/ |
| "No source maps found" | Check that ./dist contains .map files |
| Maps uploaded, still minified | Ensure release in init matches upload release |
| Debug IDs not found | Run sentry-cli sourcemaps inject before upload |