简体   繁体   English

AOT编译在Angular 12

[英]AOT compilation in Angular 12

Angular documentation states: Angular 文档指出:

 *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 ?因此,如果我想使用 AOT 编译我的Angular 12 应用程序,我只需要键入ng build而不添加--prod并且不在angular.jsonpackage.json中添加特定配置?

This is the ng build command insieme my package.json:这是我的 package.json 中的ng 构建命令:

...
"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谢谢你的帮助

You don't need to explicitly include the --prod command for production build - given that you're using the latest version of Angular ie v12 I gather.您不需要为生产构建显式包含--prod命令 - 假设您使用的是最新版本的 Angular,即我收集的 v12。

The default angular.json file includes a profile section about the production build and you can leave it as it is.默认的 angular.json 文件包含一个关于生产构建的配置文件部分,您可以保持原样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM