Angular CLI ng run 命令


本章通过示例解释 ng run 命令的语法、参数和选项。

语法


ng run 命令的语法如下:

ng run project:target[:configuration]

ng run 命令run Architect 目标,其中包含在项目中 angular.json 中定义的可选自定义构建器配置。这里的 project 是 angular.json 中定义的应用程序的名称。

论据


ng run 命令的参数如下:

序号. 参数和语法 描述
1 <目标> 要run 的架构师目标。

Options


选项是可选参数。

序号. 选项和语法 描述
1 --配置=配置

命名构建器配置,在 angular.json 的“配置”部分中定义。构建器使用命名配置来run 给定的目标。

别名:-c。

2 --help=true|false|json|JSON

在控制台中显示此命令的帮助消息。

默认值:假。

首先移动到使用更新的角度项目 生成 命令,然后run 命令。本章可在 https://www.newbiego.com/angular_cli/angular_cli_ng_generate.htm。

例子


下面给出一个 ng run 命令的例子:

\>Node\>NewbieGo> ng run NewbieGo:build
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.

chunk {polyfills} polyfills-es2015.js, polyfills-es2015.js.map (polyfills) 141 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 656 kB [initial] [rendered]
chunk {main} main-es2015.js, main-es2015.js.map (main) 12.9 kB [initial] [rendered]
chunk {main} main-es5.js, main-es5.js.map (main) 15.1 kB [initial] [rendered]
chunk {runtime} runtime-es2015.js, runtime-es2015.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {runtime} runtime-es5.js, runtime-es5.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {styles} styles-es2015.js, styles-es2015.js.map (styles) 12.4 kB [initial] [rendered]
chunk {styles} styles-es5.js, styles-es5.js.map (styles) 13.9 kB [initial] [rendered]
chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 2.66 MB [initial] [rendered]
chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 3.11 MB [initial] [rendered]
Date: 2020-06-04T02:31:28.919Z - Hash: dd73885c28e550d01341 - Time: 13742ms

这里 ng build 命令已经成功构建了我们的项目 NewbieGo。