How to speed up the Angular build process

前端 未结 6 1813
予麋鹿
予麋鹿 2020-12-23 11:17

After making some changes in my TypeScript files, each build takes over 20 minutes. I run this command: ng build --output-path=..\\..\\static\\angularjs.

<
6条回答
  •  情歌与酒
    2020-12-23 12:07

    I've found that for me, this issue was solved by using the watch flag, i.e.

    ng build --watch=true
    

    This runs constantly, and automatically builds files only when saved. It has dropped my build time from 8 sec to <1 sec for small changes in code, since it only generates .js files for what actually changed.

    From https://angular.io/guide/deployment

    The ng build command generates output files just once and does not serve them.

    The ng build --watch command will regenerate output files when source files change. This --watch flag is useful if you're building during development and are automatically re-deploying changes to another server.

    You should probably use ng build with the necessary options when you are building for production so that the necessary optimizations are completed.

提交回复
热议问题