Skip to main content
Source maps allow Sonarly to show you the original source code location when errors occur, instead of minified code.

Step 1: Enable Sourcemap Generation

Add the sourcemap configuration to your build tool:
// vite.config.ts
export default defineConfig({
  build: { sourcemap: 'hidden' }
})

Step 2: Add Sourcemap Uploader to Build Script

Add the sourcemap uploader to your package.json build script. Use the correct folder path for your framework:
FrameworkConfig file to detectSourcemap folder
Vitevite.config.ts or vite.config.js./dist/assets/
Next.jsnext.config.js or next.config.mjs./.next/static/chunks/
Create React Appreact-scripts in package.json./build/static/js/
Nuxt 3nuxt.config.ts./.output/public/_nuxt/
Vue CLI@vue/cli-service in package.json./dist/js/
Remixremix.config.js./public/build/
SvelteKitsvelte.config.js./build/_app/immutable/

Build Script Examples

{
  "scripts": {
    "build": "vite build && npx @sonarly/sourcemap-uploader --api-key=YOUR_PROJECT_KEY ./dist/assets/ || true"
  }
}
The || true at the end ensures your build doesn’t fail if the sourcemap upload fails (e.g., network issues).

Verify

After deploying, check that:
  1. .map files are generated in your build folder
  2. Upload command shows success (no 404 errors)
  3. Errors in your Sonarly dashboard show original source code locations

Configure backend traces

Link backend errors to frontend sessions