sentry-docs
sentry-docs copied to clipboard
Document that JS source maps are not required to be shipped in production
Core or SDK?
Platform/SDK
Which part? Which one?
Source Maps (JS)
Description
I do want sourcemaps but I do not want to ship them in production. There's no information around this under https://docs.sentry.io/platforms/javascript/sourcemaps/ but for some reason it's only mentioned for the NextJS "platform": https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map:
Depending on your deployment setup, adding
sentry/nextjsto your app may cause your source code to be visible in browser devtools when it wasn't before. (This happens because of the default behavior of webpack's source-map built-in devtool.) To prevent this, you can usehidden-source-maprather thansource-map, which will prevent your built files from containing asourceMappingURLcomment, thus making sourcemaps invisible to the browser. To usehidden-source-map, add asentryobject tonextConfigabove, and set thehideSourceMapsoption to true: …
I am not using NextJS, but I do use Webpack. I only found this through Github issues after searching for an answer. I think it would help others too that don't use NextJS if this would be fully documented.
Related open issues I found while searching for an answer around this:
- https://github.com/getsentry/sentry-javascript/issues/4489
- https://github.com/getsentry/sentry/issues/20916
Suggested Solution
- Hoist or also call out that source maps are not required to be shipped in production in the general docs, and that one can configure one's build tooling to keep them hidden, e.g. under https://docs.sentry.io/platforms/javascript/sourcemaps/ or the troubleshooting sub-page perhaps
- Document under each build tool page how to configure for public vs hidden source maps, e.g. for Webpack I'd probably expect a mention about
devtool: 'hidden-source-map'under this sub-section: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/webpack/#configuration
Assigning to @getsentry/support for routing ⏲️
Hey, thank you for raising this, and sorry this kind of fell of the radar.
We'll try to update the docs to clarify this even outside of Next.js!