0

Angular documentation states:

 *Ahead-of-Time (AOT), which compiles your application and libraries at build time. This is the 
 default since Angular 9.*

So if I want to compile for production my Angular 12 application with AOT I just need to type ng build without adding --prod and without adding specific configuration neither in angular.json nor in package.json?

This is the ng build command insieme my package.json:

...
"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "prepare": "husky install"
  },
...

Thank for you help

Matt
  • 265
  • 4
  • 17

1 Answers1

1

You don't need to explicitly include the --prod command for production build - given that you're using the latest version of Angular i.e. v12 I gather.

The default angular.json file includes a profile section about the production build and you can leave it as it is.

Ali Celebi
  • 824
  • 1
  • 10
  • 19
  • Yes, I'm using Angular 12.0.0. Thank for your help – Matt Oct 01 '21 at 10:00
  • From you answer I didn't get if with 'ng build' command Angular 12 will compile with AOT without any specific configuration needed – Matt Oct 01 '21 at 11:59
  • @Matt - There is a configuration section within the angular.json file for production build process. This section includes a property called "aot". It's set to true by default which enables the AOT build. – Ali Celebi Oct 01 '21 at 13:12
  • 1
    There isn't any property call aot inside my angular.json. That's why I have this doubt – Matt Oct 01 '21 at 13:19
  • 1
    @Matt - that's strange! Newly created Angular app has the AOT property and its set to true. You can modify your angular.json file to include this flag. Please see the following Angular v12 app created from scratch here --> https://stackblitz.com/edit/angular-ivy-q4qs63?file=angular.json – Ali Celebi Oct 01 '21 at 13:23
  • 2
    In Angular 12 AOT is the default so the option is not even there on a newly created project. – AsGoodAsItGets Nov 26 '21 at 16:52