Source Maps

Upload your source maps to Sentry to enable readable stack traces in your errors.

Note: Source maps are only generated and uploaded during production builds (npm run build). Development builds (npm run dev) do not generate source maps for upload.

See how uploading source maps lets you see the exact line of code that caused an error:

Make sure you add your auth token to your CI, if you are using one to deploy your application.

Add your auth token to your environment:

.env
Copied
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
Using environment variables in Vite configs

Vite doesn't automatically load .env files into process.env when evaluating the config file. If you store your auth token in a .env file and want to access it via process.env.SENTRY_AUTH_TOKEN, use Vite's loadEnv helper:

vite.config.js
Copied
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), "");

  return {
    plugins: [
      sentryVitePlugin({
        authToken: env.SENTRY_AUTH_TOKEN,
        // ...
      }),
    ],
  };
});

Alternatively, use a .env.sentry-build-plugin file, which the Sentry plugin reads automatically.

Configure sentryTanstackStart in your vite.config.ts:

vite.config.ts
Copied
import { defineConfig } from "vite";
import { sentryTanstackStart } from "@sentry/tanstackstart-react/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";

export default defineConfig({
  plugins: [
    tanstackStart(),
    // other plugins - sentryTanstackStart should be last
    sentryTanstackStart({
      org: "___ORG_SLUG___",
      project: "___PROJECT_SLUG___",
      authToken: process.env.SENTRY_AUTH_TOKEN,
    }),
  ],
});

The plugin, by default, automatically enables hidden source maps and deletes .map files after upload.

Configure source map behavior using the plugin options, for example:

vite.config.ts
Copied
import { defineConfig } from "vite";
import { sentryTanstackStart } from "@sentry/tanstackstart-react/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";

export default defineConfig({
  plugins: [
    tanstackStart(),
    sentryTanstackStart({
      org: "___ORG_SLUG___",
      project: "___PROJECT_SLUG___",
      authToken: process.env.SENTRY_AUTH_TOKEN,

      sourcemaps: {
        assets: ["./dist/**/*"],
        ignore: ["**/node_modules/**"],
        filesToDeleteAfterUpload: [
          "./**/*.map",
          ".*/**/public/**/*.map",
          "./dist/**/client/**/*.map",
        ],
      },
    }),
  ],
});

If you're experiencing issues with source maps, see Troubleshooting Source Maps.

Was this helpful?
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").