Webpack-dev-server: v4.0.0-beta.0: dev server fails in multiple configs env with proxy property.

Created on 1 Dec 2020  路  3Comments  路  Source: webpack/webpack-dev-server

  • Operating System: OSX 10.14.6
  • Node Version: v14.15.1
  • NPM Version: 6.14.8
  • webpack Version: 5.9.0
  • webpack-dev-server Version: v4.0.0-beta.0
  • Browser: any
  • [x] This is a bug
  • [ ] This is a modification request

Code


checkout repo: [email protected]:sprilukin/webpack-dev-server-beta4-proxy-issue.git
or use these code snippets:

// webpack.config.js
module.exports = [
    {
        entry: {
            'entry1': './src/entry1'
        },
        devServer: {
            proxy: {
                '*': {
                    target: "http://localhost:8080",
                    bypass: function (req) {
                        return req.url;
                    }
                }
            }
        }
    },
    {
        entry: {
            'entry2': './src/entry2'
        }
    }
];

// ./src/entry1
console.log("Entry 1");
// ./src/entry2
console.log("Entry 2");

Expected Behavior

dev server started successfully

Actual Behavior

There is an error in the console during starting dev server:

(node:8289) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'level' of undefined
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:203:57
    at Array.map (<anonymous>)
    at Server.setupProxyFeature (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:169:62)
    at Object.proxy (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:369:16)
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:449:24
    at Array.forEach (<anonymous>)
    at Server.setupFeatures (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:448:22)
    at new Server (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:68:10)
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/@webpack-cli/serve/lib/startDevServer.js:34:24
    at Array.forEach (<anonymous>)

For Bugs; How can we reproduce the behavior?

  • chekcout this repo [email protected]:sprilukin/webpack-dev-server-beta4-proxy-issue.git
  • npm install && npm run start

Here is the piece of code where exception is actually thrown:

          proxyOptions.logLevel = getLogLevelForProxy(
            this.compiler.options.infrastructureLogging.level
          );

Here this.compiler.options is an Array, not an Object in case of multiple webpack config env.

bug

Most helpful comment

I still get the same issue, has this fix been tagged?

All 3 comments

Yep, bug

I still get the same issue, has this fix been tagged?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hnqlvs picture hnqlvs  路  3Comments

movie4 picture movie4  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

eyakcn picture eyakcn  路  3Comments

piotrszaredko picture piotrszaredko  路  3Comments