Create Sourcemap in Prod but do not Include in apk

Is there a way of creating a file but not copying it over to the apk for release?

My use case is for error reporting. I can upload the main.js and to sentry and it will generate a pretty stacktrace. However I don’t want to include it in the apk.

I know I can switch the sourcemap on and off but not how to do the above. Does anyone have any ideas?


@ionic/app-scripts              : 1.3.8
Ionic Framework                 : ionic-angular 3.4.1
1 Like

Did you find a way? I’m after the source map for the same reason (uploading to Sentry).

You can make a build with sourcemaps like this :
./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build --prod --generateSourceMap true

I use this to analyze my source maps via source-map-explorer.

If you create a npm run command in your package.json you don’t have to put the whole path. Hope this works for you.

1 Like

The way I’m doing it is putting a build task in to move the map out to a different folder before the APK is built. Then as part of a gulp task to create the Sentry release I shift it back (to preserve the relative path) and at the end of the task shift it back.

Not ideal but it works

Yes that creates the source map but can you confirm that the source map is not included in the APK by this method?

They won’t go in the APK, when you make your release build via ionic cordova build android --prod --release the project is build again and the source maps are not created.

Can you confirm that the source map really matches the one in release built when you run 2 separate builds (first for source map, second for release build)?

Does anybody have a working script/hook to automate that copying around (maybe even with automatic sentry upload?)