1

I wanted to add a question within the comment section of this post: Angular 2 AOT vs JIT, but I don't have enough rep points yet.

I have an Angular app that shows errors when I build but not in dev. I understand the desire to get quick feedback in dev but for this application it is causing issues in the gratification of quick deployment after working in the dev enviroment for extended time. Instead of doing ng serve to get the feedback and then do ng build right after to make sure at a later time I will be able to deploy; is there a flag I can add to ng serve that will do this for me?

At the moment I use ng serve --aot but that is not strict enough to show errors that will fail at build. Right now the application I have is not that big, so I will find it acceptable if my ng serve loads slower.

Here's a snippet of my package.json:

{
  "name": "XXXXXXX",
  "url": "XXXXXXX",
  "version": "0.0.1",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --aot",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.1.2",
    "@angular/cdk": "^5.0.2",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "^5.0.2",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/platform-server": "^5.0.0",
    "@angular/router": "^5.0.0",
    "angular2-jwt": "^0.2.3",
  },
  "devDependencies": {
    "@angular/cli": "^1.5.5",
    "@angular/compiler-cli": "^5.0.0",
    "@types/google.analytics": "0.0.36",
    "@types/jasmine": "^2.5.38",
    "@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.0.0",
    "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.4.2"
  }
}
runningraptor
  • 339
  • 1
  • 6
  • 19

1 Answers1

0

Here is the documentation of all the build options of ng serve

https://github.com/angular/angular-cli/wiki/serve

For your case, try

ng serve --e=prod

or

ng serve --aot --e=prod

Hope this works.

Also try --source-maps=false. This looks like speeding up things.

srikanth_k
  • 2,807
  • 3
  • 16
  • 18
  • Thank you! The first one wasn't strict enough, but the second solution worked perfectly! – runningraptor Jan 24 '18 at 22:59
  • 1
    adding `--source-map=false` can greatly speed things up. Obviously the `prod` and `aot` slow things down - and if you're looking to just fix all those silly small things this should speed up the process. – Simon_Weaver Jun 02 '18 at 19:50