Ionic-app-scripts: Source maps are not disabled in prod build

Created on 11 May 2017  路  16Comments  路  Source: ionic-team/ionic-app-scripts

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/

Short description of the problem:

Issuing ionic build android --release --prod creates production apk which still includes source maps. Those must be disabled in the production build

What behavior are you expecting?

Source maps disabled in production build.

Steps to reproduce:

  1. make sure that in package.json
    "ionic_generate_source_map": true
  2. run ionic build android --release --prod
    Production APK file created still contains source map files
insert any relevant code between the above and below backticks

Which @ionic/app-scripts version are you using?
1.3.7

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Most helpful comment

using this will fix it
ionic-app-scripts build --prod --generateSourceMap false

All 16 comments

Hi @ryaa,

Since you have the ionic_generate_source_map flag set to true, it makes sense that the source map is preserved. This is by design.

Thanks,
Dan

Setting this to false gives an error. The same as here https://github.com/driftyco/ionic-app-scripts/issues/934

So I don't see any way to disable source maps for the PROD build. That's the problem

Dan, here you state that source maps are disabled for prod build by default - see comment made on Jan 11 https://github.com/driftyco/ionic-app-scripts/issues/289#issuecomment-271899536

Not using eval source maps will fix it. eval source maps for prod would be very bad.

Thanks,
Dan

Dan, are you saying that if i use anything besides eval (for example "ionic_source_map_type": "#inline-source-map" or "source-map") and "ionic_generate_source_map": is true the ionic-app-scripts will disable the source maps by default in PROD build?

The problem is that it is not possible to create PROD build without source maps. The "ionic_generate_source_map": false configuration does not work (gives an error) and if it is true it includes source maps into the production build.

@ryaa,

Remove ionic_generate_source_map from package.json unless you want a source map.

Remove ionic_source_map_type as well.

You should be good to go.

Thanks,
Dan

using this will fix it
ionic-app-scripts build --prod --generateSourceMap false

Thank you very much @aelsharif
This did the trick!

Note that "ionic_source_map_type" must be "source-map"
If this is "ionic_source_map_type": "#inline-source-map" it still triggers the error even with --generateSourceMap false

@ryaa if ionic_source_map_type is source-map, then I don't get any source maps when building debug builds!

@cocowalla what is the ionic-app-scripts version? and what is the value for "ionic_generate_source_map"? if it is false and you use the latest ionic-app-scripts version that this is expected behaviour, I think

@ryaa app-scripts are at 2.1.4, but this problem has persisted for many previous versions.

ionic_generate_source_map is not set in package.json. if I set it to true and ionic_source_map_type is source-map, I still don't get any source maps - I only get them using #inline-source-map - but then of course I can't built with --prod --release!

@cocowalla strange. I use 2.1.3 and can generate source maps with ionic_generate_source_map true and ionic_source_map_type source-map settings...

@ryaa it doesn't work for me, or anyone else on my team. In on Windows, if it makes any difference:

cli packages: (C:\MyProj\node_modules)

    @ionic/cli-plugin-proxy : 1.4.6
    @ionic/cli-utils        : 1.9.2
    ionic (Ionic CLI)       : 3.9.2

global packages:

    Cordova CLI : not installed

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 26.0.2
    Node              : v6.11.0
    npm               : 3.10.10
    OS                : Windows 7

I have the same problem

ionic cordova build browser --prod --release --generateSourceMap false

Appears to do nothing -- how does one disable sourcemaps completely in production?

Source map error: request failed with status 404 Resource URL: https://domain.com/build/main.js Source Map URL: /path/to/local/dev/filesystem/www/build/main.js.map

Even if the sourcemap 404s I'd really prefer not advertising my local filesystem to the world.

I disabled source map completely from the prod release by doing the below:
1) set the below in package.json

"config": {
    "ionic_bundler": "webpack",
    "ionic_generate_source_map": false,
    "ionic_source_map_type": "source-map"
  }

2) issue
ionic cordova build android --release --prod

This works with ionic cli 3.19.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriswep picture chriswep  路  72Comments

ihadeed picture ihadeed  路  97Comments

shlomiassaf picture shlomiassaf  路  83Comments

vigneshmahalingam picture vigneshmahalingam  路  77Comments

jgw96 picture jgw96  路  73Comments