0

I have following script in my angular2 project, usually when I want to run project the command I use will be ng serve... (start-prod, start-uat, start-dev)

However, after I read about AOT https://angular.io/guide/aot-compiler#workflow-and-convenience-script I try to follow the step and don't know how to start application because, ng serve is only thing I used at the beginning.

what script should I use to start ?

  "scripts": {
    "ng": "ng",
    "start-prod": "ng serve --environment=prod --deploy / --proxy-config proxy.conf.json",
    "start-uat": "ng serve  --environment=uat --deploy / --proxy-config proxy.conf.json",
    "start-dev": "ng serve  --environment=dev --deploy / --proxy-config proxy.conf.json",
    "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
    "build-prod": "ng build  --environment=prod --aot false output-hashing none --deploy /",
    "build-uat": "ng build  --environment=uat --aot false output-hashing none --deploy /",
    "build-dev": "ng build  --environment=dev --aot false output-hashing none --deploy /",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },

Also, I want to run AOT with ngc not AOT from web pack, I have issues on using custom decorator https://github.com/rangle/angular-2-aot-sandbox and I want to try this build on production

Jongz Puangput
  • 5,527
  • 10
  • 58
  • 96
  • try this `ng serve --aot` https://stackoverflow.com/questions/39167600/how-to-use-ahead-of-time-compiler-with-angular-cli-webpack – Anton Lee Sep 06 '17 at 05:51

2 Answers2

1

You can run:

ng build -prod

This will create files in your dist folder that will be aot build.

aot is by default in prod. so specifying --aot doesn't make any effect. see this answer.

Peter
  • 10,492
  • 21
  • 82
  • 132
  • but, I want to run AOT with ngc not AOT from web pack, I have issues on using custom decorator https://github.com/rangle/angular-2-aot-sandbox – Jongz Puangput Sep 06 '17 at 06:25
0

To make your project running you can simply fire ng serve or ng serve --aot command

Basically at the time of creating build we will use aot along with prod to minimize the size of your bundle in the production use.

These are the various command provided by angular team you run with ng .

"scripts": {
    "ng": "ng",
    "start-prod": "ng serve --environment=prod --deploy / --proxy-config proxy.conf.json",
    "start-uat": "ng serve  --environment=uat --deploy / --proxy-config proxy.conf.json",
    "start-dev": "ng serve  --environment=dev --deploy / --proxy-config proxy.conf.json",
    "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
    "build-prod": "ng build  --environment=prod --aot false output-hashing none --deploy /",
    "build-uat": "ng build  --environment=uat --aot false output-hashing none --deploy /",
    "build-dev": "ng build  --environment=dev --aot false output-hashing none --deploy /",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  }

like ng serve , ng serve --aot --prod etc

Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
  • but, I want to run AOT with ngc not AOT from web pack, I have issues on using custom decorator https://github.com/rangle/angular-2-aot-sandbox – Jongz Puangput Sep 06 '17 at 06:24