Ionic version:
[x] 4.3
Current behavior:
When executing a release build after a debug build, the www/ folder is not cleared, and the release build will have debug chunks and sourcemap files inside the apk. This causes a very big .apk.
Expected behavior:
The www/ folder should be cleared before performing a release build.
Steps to reproduce:
ionic cordova build androidionic cordova build android --prod --releaseWithout a debug build:

After a debug build:

Extracted .apk:

Workaround
Execute rm -rf ./www/ before building a release build.
Ionic info:
```
Ionic:
ionic (Ionic CLI) : 4.12.0 (C:Users\freek\AppData\Roaming\nvm\v10.15.0\node_modules\ionic)
Ionic Framework : @ionic/angular 4.3.0
@angular-devkit/build-angular : 0.13.8
@angular-devkit/schematics : 7.3.8
@angular/cli : 7.3.8
@ionic/angular-toolkit : 1.5.1
Cordova:
cordova (Cordova CLI) : 9.0.0 ([email protected])
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.1, (and 10 other plugins)
System:
Android SDK Tools : 26.1.1 (C:Users\freek\AppData\Local\Android\Sdk)
NodeJS : v10.15.0 (C:\program files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10```
Some investigation is needed here for the best solution.
There is some history/discussion about this here: https://github.com/ionic-team/ionic-cli/issues/3890
ng build --prod >> delete www before build
ionic cordova build android --prod --release >> www/ folder is not cleared
How do you workaround this bug? My app with --release flag gets double sizes when uploaded to app store.
@maidmehic Just delete the www/ folder before creating a release. Should do the trick.
Hello @FreekMencke , thanks for the response. Even if I delete www folder from platforms->ios it recreates again after ionic cordova build ios --prod --release. Should it recreate? Thanks!
@maidmehic completely normal, those are the files you built. If you don't remove it before building it though, it would still contain your debug build files. After deleting and rebuilding, it just contains the built files (the files you want).
Thanks for clarifying!
馃摑 The Ionic CLI should delete www for non-livereload builds.
Most helpful comment
ng build --prod >> delete www before build
ionic cordova build android --prod --release >> www/ folder is not cleared