Skip to content

Conversation

@nichtsam
Copy link
Contributor

Problem

When a webpage is loaded with DevTools open, the browser automatically attempts to fetch .map files if a sourceMappingURL comment is present at the end of each JavaScript file.

//# sourceMappingURL=xxx.js.map

Vite includes this comment by default when build.sourcemap is set to true.
In our case, sourcemaps are removed after the build process by the Sentry plugin, so these requests result in a large number of 404s and can cause performance issues.

Solution

Set build.sourcemap to 'hidden' in vite.config.ts.
https://vite.dev/config/build-options.html#build-sourcemap

This ensures that sourcemaps are still generated, but the sourceMappingURL comment is no longer injected into the final JS output — preventing unnecessary network requests triggered by DevTools.

@nichtsam nichtsam marked this pull request as draft April 14, 2025 15:50
@nichtsam nichtsam closed this Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant