Angular-RU / angular-cli-webpack

Webpack configuration modifier for @angular/cli
MIT License
67 stars 5 forks source link

overriding/extending devServer properties doesnt work #21

Open christianscharr opened 6 years ago

christianscharr commented 6 years ago

I am trying to enhance the default CLI configuration of webpack-dev-server. I need to set the following properties:

What I am seeing is. that ngw successfully injects this but it seems that @angular/cli overrides it afterwards... It never gets recognized by webpack-dev-server, whatever property I am setting inside "devServer"

splincode commented 6 years ago

@christianscharr you need usage proxy.conf.js for Angular

ng serve --proxy-config proxy.conf.js

const PROXY_CONFIG = {
    "/api/proxy": {
        "target": "http://localhost:3000",
        "secure": false,
        "bypass": function (req, res, proxyOptions) {
            req.headers["X-Custom-Header"] = "yes";
        }
    }
}

module.exports = PROXY_CONFIG;

for historyApiFallback you can usage workaround

  1. ng build --watch
  2. run your node server in dist directory (with your history fallback)