如何使用 ngc 启动监视模式?

How can I initiate watch mode with ngc?

我想做同样的事情,就像我在过去的 tsc 次一样:只需调用 tsc -w,如果文件发生更改,它将在飞重新编译。

不幸的是,ngc 甚至似乎对 -w 标志没有任何反应,甚至它可能的命令行参数也完全没有记录。

但是,ng build 一个 --watch 标志,同时它也可以创建 AOT 构建。因此,手表模式 ngc 是可能的。

但是如何呢?

版本 5:

您现在可以像这样使用手表模式:

ngc -w

参见 Tobias 的 this comment

The command line ngc also has a -w option now that watches the file system and we see speedups for subsequent builds of up to 10x, as we have some logic in place to only compile components in node_modules 1x.

4 之前的版本

目前ngc不支持手表模式。它被 Tobias Bosch 确定为优先功能。 Here is the video 他在哪里谈到的。

Angular5 的变更日志指出 ngc watch 现在是一回事了! https://github.com/angular/angular/blob/master/CHANGELOG.md#500-pentagonal-donut-2017-11-01

Features: compiler-cli: add watch mode to ngc (#18818) (06d01b2)