Angular CLI终极参考指南
如果翻译内容对你产品困扰,可查看原文The Ultimate Angular CLI Reference Guide
运行项目
想在浏览器中查看项目,可以跳转到相应目录
$ cd my-app
运行
$ ng serve
在为4200端口上启动开发服务
** NG Live Development Server is running on http://localhost:4200. **
3935ms building modules
Hash: fd7ad6cf3503757e22e0
Version: webpack 2.1.0-beta.25
Time: 6526ms
Asset Size Chunks Chunk Names
main.bundle.js 2.78 MB 0, 2 [emitted] main
styles.bundle.js 10.2 kB 1, 2 [emitted] styles
inline.js 5.53 kB 2 [emitted] inline
main.map 2.86 MB 0, 2 [emitted] main
styles.map 14.1 kB 1, 2 [emitted] styles
inline.map 5.59 kB 2 [emitted] inline
index.html 472 bytes [emitted]
assets/.npmignore 0 bytes [emitted]
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 2.81 kB 0
webpack: bundle is now VALID.
现在你可以在浏览器上输入http://localhost:4200/ 来访问你的项目

首页
启动过程中做了这些事情:
- Angular CLI从angular-cli.json加载依赖
- Angular CLI运行webpack来构建所有js与css代码
- Angular CLI启动webpack dev server 在localhost:4200上浏览页面
注意:在执行完第三步以后,ng serve命令不会退出,并输出执行情况
与此同时,由于该进程有LiveReload的支持,TA会动态监听src目录下文件的更改,当发现有文件更新,重新运行第二步,并自动刷新浏览器
要停止此进程返回命令行,可以输入ctrl+c