Reputation: 11
I'm working on a ReactJS (create-react-app) project.
I do not generate source maps in my production build. But I still want to be able to unminify code for issues in production. In an attempt to achieve this I know create releases and uploade source maps, js and css code to a specific release and dist in Sentry (using sentry-cli).
export SENTRY_ORG=<org slug>
export SENTRY_PROJECT=<project name>
export SENTRY_RELEASE=<release>
export SENTRY_DIST=<dist>
sentry-cli releases new "$SENTRY_RELEASE"
sentry-cli releases set-commits "$SENTRY_RELEASE" --auto
sentry-cli releases finalize "$SENTRY_RELEASE"
sentry-cli sourcemaps inject --org $SENTRY_ORG --project $SENTRY_PROJECT --release $SENTRY_RELEASE ./build
sentry-cli sourcemaps upload --org $SENTRY_ORG --project $SENTRY_PROJECT --release $SENTRY_RELEASE --dist $SENTRY_DIST --strip-prefix / ./build
I can see that a new version is created in sentry and that the artifacts are attached to the release (1 css file, 1 js file, 1 js.map file). When an issue occurs in production, the issue is linked to the correct version and dist, BUT code is still not minified.
I suspect it is because I do two separate builds (one build with source maps and another build without). But there must be a way to connect them as the code is the same.
If I include the source maps in the production build, everything works as expected.
I have also tried only doing one build (with source maps), where I first uploaded it to sentry and then deleted source map and ref to source map and use the build as production build. I also tried changing the sourceMappingUrl to the artifact path in sentry (~/static/js/<name>.js.map). Nothing worked.
So my question is: How can I unminify code in sentry when my production build does not have sourcemaps?
Upvotes: 1
Views: 1321
Reputation: 241
When you run the sourcemaps inject
command you modify your bundles. You need to deploy the files that you ran the sourcemaps inject
command on, otherwise the SDK cannot assign debug IDs to the error stack frames.
Upvotes: 0