如何使用 angular-cli 启用 watch 进行构建?
How do I build with watch enabled using angular-cli?
我不想使用服务,我知道它会监视更改、构建和服务。
我想在变化的基础上再接再厉。
根据"ng help",构建带参数--watch
ng build Builds your app and places it into the output
path (dist/ by default).
--watch (Boolean) (Default: false)
aliases: -w --watcher (String)
我尝试了 -w 和 --watcher 但它只是给出了错误。
>ng build -w
Path must be a string. Received null
我不知道这是一个错误还是只是没有记录,但您似乎需要添加一个输出路径以使用 ng build -o dist -w
观看,而 dist 是您的输出路径。
更新:
命令现在是:ng build -op dist -w
更新二:
命令现在是:ng build --output-path dist --watch
ng build --watch
对我有用
如果您使用的是 npm run build
,请将 package.json
文件更新为
"scripts":{"build":"ng build --watch"}
和运行 npm run build
照常
确保在 angular-cli.json
中正确设置了应用的 outDir
参数
ng build --watch
寻找路径:dist
来观察变化。但是根据 Angular 的新版本,默认输出路径将是 dist/<project-name>
.
所以你需要通过命令行提到输出目录,比如
ng build --output-path dist --watch
或
您可以将 angular.json... -> options -> outputPath: dist/<project-name>
中的默认位置更改为 dist
,只需 运行 ng build --watch
构建和监视的命令 AngularJs:ng build --poll=2000 --watch
我不想使用服务,我知道它会监视更改、构建和服务。 我想在变化的基础上再接再厉。 根据"ng help",构建带参数--watch
ng build Builds your app and places it into the output path (dist/ by default). --watch (Boolean) (Default: false) aliases: -w --watcher (String)
我尝试了 -w 和 --watcher 但它只是给出了错误。
>ng build -w
Path must be a string. Received null
我不知道这是一个错误还是只是没有记录,但您似乎需要添加一个输出路径以使用 ng build -o dist -w
观看,而 dist 是您的输出路径。
更新:
命令现在是:ng build -op dist -w
更新二:
命令现在是:ng build --output-path dist --watch
ng build --watch
对我有用
如果您使用的是 npm run build
,请将 package.json
文件更新为
"scripts":{"build":"ng build --watch"}
和运行 npm run build
照常
确保在 angular-cli.json
中正确设置了应用的outDir
参数
ng build --watch
寻找路径:dist
来观察变化。但是根据 Angular 的新版本,默认输出路径将是 dist/<project-name>
.
所以你需要通过命令行提到输出目录,比如
ng build --output-path dist --watch
或
您可以将 angular.json... -> options -> outputPath: dist/<project-name>
中的默认位置更改为 dist
,只需 运行 ng build --watch
构建和监视的命令 AngularJs:ng build --poll=2000 --watch