Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Source maps are not disabled in prod build #977

Closed
ryaa opened this issue May 11, 2017 · 16 comments
Closed

Source maps are not disabled in prod build #977

ryaa opened this issue May 11, 2017 · 16 comments

Comments

@ryaa
Copy link

ryaa commented May 11, 2017

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)

@danbucholtz
Copy link
Contributor

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

@ryaa
Copy link
Author

ryaa commented May 11, 2017

Setting this to false gives an error. The same as here #934

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

@ryaa
Copy link
Author

ryaa commented May 11, 2017

Dan, here you state that source maps are disabled for prod build by default - see comment made on Jan 11 #289 (comment)

@danbucholtz
Copy link
Contributor

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

Thanks,
Dan

@ryaa
Copy link
Author

ryaa commented May 12, 2017

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.

@danbucholtz
Copy link
Contributor

@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

@aelsharif
Copy link

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

@ryaa
Copy link
Author

ryaa commented Jun 12, 2017

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

@cocowalla
Copy link

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

@ryaa
Copy link
Author

ryaa commented Sep 14, 2017

@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

@cocowalla
Copy link

@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!

@ryaa
Copy link
Author

ryaa commented Sep 14, 2017

@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...

@cocowalla
Copy link

@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

@fdambrosio
Copy link

I have the same problem

@godenji
Copy link

godenji commented Feb 2, 2018

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.

@ryaa
Copy link
Author

ryaa commented Feb 11, 2018

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"
  }
  1. issue
    ionic cordova build android --release --prod

This works with ionic cli 3.19.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants