1

I am working on a Angular-4 app, it is very robust and it takes forever to compile when I run ng build --prod (or --aot). Most of the time I simply run ng build.

Something I have noticed is that ng build does not check my code as the ng build --prod does (it does not check types, missing variables, unused dependencies, etc).

How can I add this checking without having to go through the whole process that --prod does?

I don't know if this helps, but this is my package.json:

{
  "name": "www-admin",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.0",
    "@angular/animations": "^4.1.3",
    "@angular/cdk": "^2.0.0-beta.11",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.6",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@ngui/auto-complete": "^0.14.4",
    "@ngx-translate/core": "^7.0.0",
    "@ngx-translate/http-loader": "^0.1.0",
    "@types/lodash": "^4.14.107",
    "@types/moment": "^2.13.0",
    "angular-2-dropdown-multiselect": "^1.6.0",
    "angular-2-local-storage": "^1.0.1",
    "angular2-hotkeys": "^2.0.3",
    "angular2-modal": "^2.0.3",
    "angular2-moment": "^1.8.0",
    "angular2-toaster": "^4.0.1",
    "angular4-carousel": "^3.1.8",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "jquery": "^3.3.1",
    "lodash": "^4.17.5",
    "moment": "^2.18.1",
    "mydatepicker": "^2.0.31",
    "ng-drag-drop": "^4.0.1",
    "ng-http-loader": "^0.3.3",
    "ng-pick-datetime": "^5.0.0-beta.15",
    "ng-sidebar": "^5.1.0",
    "ng2-auto-complete": "^0.12.0",
    "ng2-bootstrap": "^1.6.3",
    "ng2-bootstrap-modal": "https://github.com/Sky4CE/ng2-bootstrap-modal/tarball/v.1.0.2",
    "ng2-dragula": "^1.5.0",
    "ng2-tooltip": "0.0.7",
    "ngx-bootstrap": "^1.6.6",
    "ngx-chips": "^1.5.2",
    "ngx-tooltip": "0.0.9",
    "rxjs": "^5.1.0",
    "ts-md5": "^1.2.2",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.2",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^3.3.1",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "2.3.0"
  }
}
Shubham Verma
  • 8,783
  • 6
  • 58
  • 79
Multitut
  • 2,089
  • 7
  • 39
  • 63

1 Answers1

0

This version (and higher) will reduce the build time for you.

@angular/cli": "1.7.0-beta.0

I personally cut my build time from 30 minutes to 3 minutes.

You can also use --build-optimizer see this link for more details:
https://github.com/angular/angular-cli/wiki/build

Nadhir Falta
  • 5,047
  • 2
  • 21
  • 43
  • It would probably be best to upgrade to Angular 6 - see https://stackoverflow.com/questions/43931986/how-to-upgrade-angular-cli-to-the-latest-version – GreyBeardedGeek Jul 12 '18 at 03:27