Build process taking too much time to complete

#1

While doing ionic cordova build android/ios --prod the webpack process taking a long time to complete.

error

Package.json:

{
"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/animations": "5.0.3",
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@ionic-native/browser-tab": "4.5.2",
    "@ionic-native/core": "4.5.2",
    "@ionic-native/device": "4.5.2",
    "@ionic-native/keyboard": "4.5.2",
    "@ionic-native/network": "4.5.2",
    "@ionic-native/spinner-dialog": "4.5.2",
    "@ionic-native/splash-screen": "4.5.2",
    "@ionic-native/status-bar": "4.5.2",
    "@ionic/storage": "2.1.3",
    "cordova-android": "6.2.0",
    "cordova-ios": "4.4.0",
    "cordova-plugin-browsertab": "^0.1.1",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-native-spinner": "^1.1.3",
    "cordova-plugin-network-information": "^1.3.4",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.4.0",
    "cordova-plugin-whitelist": "^1.3.1",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.5",
    "typescript": "2.4.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-browsertab": {},
      "cordova-plugin-native-spinner": {}
    },
    "platforms": [
      "android"
    ]
  }
}
#2

This is because you use “–prod”

#3

If you want to test on your device with AOT but not the amount of minification and bundling try
ionic cordova build android --ngc

#4

And as cruel as it may sound: A faster HD/SSD, CPU and RAM might help as well.

#5

I dont think its an Ionic issue. It depends on your Hardware and also on your Project. A big project will always take longer to get a native production build .

#6

I tried after reducing the number of pages
but there is no difference in the build time?!
build-time

#7

I would suggest creating a blank project and copy the src data into the new blank project, add any import required and Android folder.

#8

Also: Any post without the corresponding ionic infooutput is pretty much worthless. We have to know your environment. For you @DrNVS e.g. it seems you are using a pretty old version of ionic-app-scripts.

#9

Ionic:

ionic (Ionic CLI) : 4.0.0 (C:\Users\drnvs\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.7.1
@ionic/app-scripts : 3.0.0

Cordova:

cordova (Cordova CLI) : not installed
Cordova Platforms : none

System:

Android SDK Tools : 26.1.1
NodeJS : v7.8.0 (C:\Program Files\nodejs\node.exe)
npm : 4.2.0
OS : Windows 10

Environment:

ANDROID_HOME : C:\Users\drnvs\AppData\Local\Android\sdk

#10

Yep, super old. Update.
(You might want to use https://update.ionic.zone for help to update your whole project)

#11

Even after updates to latest App Scripts, its getting too late to build, please help

K:\ionic\paranthaman>ionic info

Ionic:

ionic (Ionic CLI) : 4.0.0 (C:\Users\drnvs\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0

System:

Android SDK Tools : 26.1.1
NodeJS : v7.8.0 (C:\Program Files\nodejs\node.exe)
npm : 4.2.0
OS : Windows 10

Environment:

ANDROID_HOME : C:\Users\drnvs\AppData\Local\Android\sdk

#12

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

How long does it take now?

#13

I checked and found as below:
K:\ionic\paranthaman>cordova -v
8.0.0

K:\ionic\paranthaman>npm update -g cordova

K:\ionic\paranthaman>cordova -v
8.0.0

K:\ionic\paranthaman>cordova platform list
Installed platforms:
android 7.0.0
Available platforms:
browser ~5.0.1
ios ~4.5.4
osx ~4.0.1
windows ~5.0.0
www ^3.12.0

K:\ionic\paranthaman>cordova plugin list
cordova-plugin-device 2.0.2 “Device”
cordova-plugin-file 6.0.1 “File”
cordova-plugin-ionic-keyboard 2.1.2 “cordova-plugin-ionic-keyboard”
cordova-plugin-ionic-webview 2.0.2 “cordova-plugin-ionic-webview”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-whitelist 1.3.3 “Whitelist”

K:\ionic\paranthaman>npm outdated
Package Current Wanted Latest Location
@angular/animations 5.2.11 5.2.11 6.1.3 paranthaman
@angular/common 5.2.11 5.2.11 6.1.3 paranthaman
@angular/compiler 5.2.11 5.2.11 6.1.3 paranthaman
@angular/compiler-cli 5.2.11 5.2.11 6.1.3 paranthaman
@angular/core 5.2.11 5.2.11 6.1.3 paranthaman
@angular/forms 5.2.11 5.2.11 6.1.3 paranthaman
@angular/http 5.2.11 5.2.11 6.1.3 paranthaman
@angular/platform-browser 5.2.11 5.2.11 6.1.3 paranthaman
@angular/platform-browser-dynamic 5.2.11 5.2.11 6.1.3 paranthaman
@ionic-native/core 4.11.0 4.11.0 4.12.0 paranthaman
@ionic-native/splash-screen 4.11.0 4.11.0 4.12.0 paranthaman
@ionic-native/status-bar 4.11.0 4.11.0 4.12.0 paranthaman
cordova-android 7.0.0 7.0.0 7.1.1 paranthaman
ionicons 3.0.0 3.0.0 4.3.0 paranthaman
rxjs 5.5.11 5.5.11 6.2.2 paranthaman
typescript 2.6.2 2.6.2 3.0.1 paranthaman

K:\ionic\paranthaman>

#14

This one. But the article I linked to explains that quite extensively.

#15

is it necessary to update ionic cordova plugin to latest version?
or is it enough keeping to wanted version?!
I found the list of all the plugins are in the wanted version
plug-in-version

#16

“Wanted” in this context means what you (or a tool you used to install this) defined as the “wanted” version.
As I said above, your should make sure you are using up to date Cordova platforms.