Production compilation with ejected Angular 4 application produces large files

爱⌒轻易说出口 提交于 2019-12-05 03:28:34

You can eject the production version of the webpack config by using the following command:

ng eject --prod

EDIT

If you want to use both the development & production versions of the ejected webpack config, do the following:

  1. Backup your existing package.json
  2. Execute ng eject --prod (this will eject the production version of webpack config)

  3. Rename the ejected webpack.config.json to webpack.config-prod.json

  4. Restore your backed up package.json (the actual changes are pretty much the scripts and few new packages). You might also want to edit your .angular-cli.json and change the ejected property to false.
  5. Execute ng eject (this will eject the development version).

You're now left with a production & development version of your webpack configs. Now, to compile your Angular project for production, execute webpack --config webpack.config-prod.js and you can also add this to your package.json scripts for ease.

However, this may not be the perfect method for this but this is what I did in the. If there's a better version, feel free to edit.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!