Angular CLI终极参考指南-运行

运行项目

想在浏览器中查看项目,能够跳转到相应目录css

$ cd my-app

运行html

$ ng serve

在为4200端口上启动开发服务webpack

** 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/ 来访问你的项目
首页
启动过程当中作了这些事情:git

  1. Angular CLI从angular-cli.json加载依赖
  2. Angular CLI运行webpack来构建全部js与css代码
  3. Angular CLI启动webpack dev server 在localhost:4200上浏览页面

注意:在执行完第三步之后,ng serve命令不会退出,并输出执行状况
与此同时,因为该进程有LiveReload的支持,TA会动态监听src目录下文件的更改,当发现有文件更新,从新运行第二步,并自动刷新浏览器
要中止此进程返回命令行,能够输入ctrl+cgithub

相关文章
相关标签/搜索