Set proxy in Webpack production config Angular 2+

As I can see, there is proxy in webpack.dev.config . How do I set proxy in webpack.prod.config ? I want to call another api domain url other than self domain url.


I going to try to provide somewhat of an answer.

As Julia points out. You should not be using the webpack dev server in your production environment as it is not meant for that, so the question should not be how to configure a production proxy config with it. That being said, if you really want to you can start a webpack server with custom proxy config like so:

ng serve --proxy-conf proxy.conf.json

What you should be doing is to use webpack, through the angular/cli to build a production build with and then move those files to be served by a static file server of your choosing. Build a production bundle like so:

ng build --prod

All above taken from your link https://jhipster.github.io/using-angular/

Since you are using JHipster there are already guides and tooling on how to take your code into production. Continue your reading here: https://jhipster.github.io/production/

I hope this points you in the right direction

链接地址: http://www.djcxy.com/p/39608.html

上一篇: Javascript AWS SDK S3上传方法与正文流生成空文件

下一篇: 在Webpack生产配置中设置代理Angular 2+