React (Vite)
Applies toAlpha
When a React app builds with Vite, @openrum/sourcemap uploads Source Maps automatically at the
end of vite build, with no extra build step. Before you start, create an upload
token and store it as the CI secret
OPENRUM_UPLOAD_TOKEN.
-
Install the plugin
Section titled “Install the plugin”Add the plugin to your application as a dev dependency:
Terminal window pnpm add -D @openrum/sourcemapnpm install --save-dev @openrum/sourcemapandyarn add -D @openrum/sourcemapwork the same way. -
Enable it in the Vite config
Section titled “Enable it in the Vite config”vite.config.ts import { defineConfig } from "vite";import { openRUMSourceMaps } from "@openrum/sourcemap/vite";export default defineConfig({build: { sourcemap: "hidden" },plugins: [openRUMSourceMaps({baseUrl: process.env.OPENRUM_BASE_URL!,projectId: process.env.OPENRUM_PROJECT_ID!,release: process.env.OPENRUM_RELEASE!,commitSha: process.env.GITHUB_SHA,// token defaults to process.env.OPENRUM_UPLOAD_TOKEN}),],});build.sourcemap: "hidden"makes Vite write.mapfiles without addingsourceMappingURLcomments to the output. If you set it totrue, the plugin removes those comments for you.What the plugin does during a build is described in the overview. If the site is served from a sub-path, for example a Vite
baseof/static/app/or a CDN URL, also seturlPrefix: "static/app/"; see Artifact names. -
Make the SDK report the same Release
Section titled “Make the SDK report the same Release”Set the plugin’s
releaseand the SDK’sreleasefrom one CI variable:src/monitoring.ts init({dsn: import.meta.env.VITE_OPENRUM_DSN,release: import.meta.env.VITE_APP_RELEASE, // same as OPENRUM_RELEASE});.github/workflows/deploy.yml - name: Build and upload Source Mapsrun: pnpm buildenv:OPENRUM_BASE_URL: https://rum.example.comOPENRUM_PROJECT_ID: <your-project-id>OPENRUM_RELEASE: ${{ github.sha }}VITE_APP_RELEASE: ${{ github.sha }}OPENRUM_UPLOAD_TOKEN: ${{ secrets.OPENRUM_UPLOAD_TOKEN }} -
Verify mapping
Section titled “Verify mapping”After deploying, follow Verify mapping: confirm the Artifacts are ready on Source Map, check a real frame with the match tester, then trigger a known error. If a frame is not mapped, see Why a frame is not mapped.
For how to initialize the SDK, see Browser SDK.
Release Alpha · commit local