Source Maps
To enable readable stack traces in your Sentry errors, you need to upload your source maps to Sentry.
Upload Source Maps for a Svelte Project
This page is a guide on how to create releases and upload source maps to Sentry when bundling your Svelte app.
To generate source maps with your Svelte project, you need to set the source map compiler options in your Svelte config:
svelte.config.js
import sveltePreprocess from "svelte-preprocess";
const config = {
compilerOptions: {
enableSourcemap: true,
},
preprocess: sveltePreprocess({
sourceMap: true,
}),
};
export default config;
If you're using Vite in you Svelte project, you can use Sentry's Vite plugin for convenience:
npm install @sentry/vite-plugin --save-dev
Configure Vite to emit source maps and use the Sentry Vite plugin:
vite.config.js
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
build: {
sourcemap: true, // Source map generation must be turned on
},
plugins: [
svelte(),
// Put the Sentry vite plugin after all other plugins
sentryVitePlugin({
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: "./dist/**",
},
// Use the following option if you're on an SDK version lower than 7.47.0:
// include: "./dist",
// Optionally uncomment the line below to override automatic release name detection
// release: process.env.RELEASE,
}),
],
});
Other Bundlers
If you're using a bundler other than Vite, check out our general guide on how to upload source maps, or refer to your bundler's documentation.
By default, if Sentry can't find the uploaded files it needs, it will attempt to download them from the URLs in the stack trace. To disable this, turn off "Enable JavaScript source fetching" in either your organization's "Security & Privacy" settings or your project's general settings.
Additional Resources
- Using sentry-cli to Upload Source Maps
- 4 Reasons Why Your Source Maps Are Broken
- Debug Your Node.js Projects with Source Maps
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/svelte
- Version:
- 7.51.0
- Repository:
- https://github.com/getsentry/sentry-javascript