Angular 2 with CLI - build for production

后端 未结 9 1886
夕颜
夕颜 2021-02-01 16:18

I have freshly installed angular-cli 1.0.0.beta.17 (latest one), start new project, able to serve project on port 4200 with no problems - just standard \"app works!\" message.

9条回答
  •  一个人的身影
    2021-02-01 16:53

    try this

     ng build --env=prod
    

    The build system defaults to the dev environment which uses environment.ts, but if you do ng build --env=prod then environment.prod.ts will be used instead.

    sample result if your project is new angular cli app.

     10% building mod3439ms building modules                                                                     1ms add01564ms 917ms asset45ms emittingHash: 9216e76d6f10637c945c                  
    Version: webpack 2.1.0-beta.22
    Time: 6358ms
                Asset       Size  Chunks             Chunk Names
       main.bundle.js     2.6 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.61 MB    0, 2  [emitted]  main
           styles.map    14.2 kB    1, 2  [emitted]  styles
           inline.map    5.59 kB       2  [emitted]  inline
           index.html  482 bytes          [emitted]  
    assets/.npmignore    0 bytes          [emitted]  
    chunk    {0} main.bundle.js, main.map (main) 2.06 MB {1} [initial] [rendered]
    chunk    {1} styles.bundle.js, styles.map (styles) 9.96 kB {2} [initial] [rendered]
    chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]
    Child html-webpack-plugin for "index.html":
             Asset     Size  Chunks       Chunk Names
        index.html  2.82 kB       0       
        chunk    {0} index.html 350 bytes [entry] [rendered]
    

    Done and it's under /dist unless you have changed outDir in angular-cli.json

提交回复
热议问题