Skip to content

hide sourcemap references in build output #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

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