ng build和ngc有什么关系和区别
我知道这个问题令人困惑,因为它让我困惑了一段时间.以前我认为ngc只是另一个tsc,它将ts编译为js.ng build 是一个多合一的命令,可以同时完成 ngc 工作以及捆绑和部署已编译的 js 脚本(如 webpack).但现在我很困惑,因为我看到了 ng new 的示例项目在脚本下面
I know the question is confusing, because it confused me for some time. Previously I think ngc is just another tsc, it compile ts to js. And ng build is a all-in-one command to do both ngc work and bundle and deploy compiled js scripts (like webpack). But now i'm confused because i saw the sample project of ng new has below script
"build:prod": "ng build --prod && ngc"
"build:prod": "ng build --prod && ngc"
这两个脚本让我很困惑,我真的很想知道 ng build 和 ngc 到底是做什么的,以及为什么我们需要两者.
this scripts have both which confused me, i really want to know that exactly the ng build do and ngc do, and why we need both.
我是 Angular 4 和前端开发的新手,非常感谢您对本主题的评论.
I'm a new to anggular 4 and front end development, many thanks to you who comments on this thread.
忽略示例项目,你最初将 ngc
理解为一个 tsc
替换Angular 应用程序是正确的.
Ignore the sample project, your original understanding of ngc
as being a tsc
replacement for Angular applications is correct.
此外,如果您使用 ng build --prod
命令,您将默认使用 AOT
编译,这就是为什么要使用 ngc代码>工具.
Also if you are using the ng build --prod
command you will by default use AOT
compilation, which is why one would use the ngc
tool.