Skip to content

Serve command not passing webpack devServer config to webpack-dev-server #1469

@lukereative

Description

@lukereative

Describe the bug

Serve command not passing webpack devServer config to webpack-dev-server

webpack.dev.js

  devServer: {
    https: isUsingHTTPS && secureLocalDomain,
    host: "myreactapp.test",
    hot: true,
    port: 8080,
    publicPath: "/myreactapp",
    quiet: true,
    proxy: {
      '**': {
        target: localURL,
        secure: false,
        headers: {
          'X-Dev-Server-Proxy': localURL
        }
      }
    }
  }

command used

webpack serve --config webpack.dev.js

What is the current behavior?

The webpack server runs but doesn't pick up all the options from the devServer config. You can see this by webpack output being undefined in the CLI output, but also the proxy was also not working.

ℹ 「wds」: Project is running at http://myreactapp.test:8080/
ℹ 「wds」: webpack output is served from undefined
ℹ 「wds」: Content not from webpack is served from /path/to/my/reactapp

To Reproduce

Relevant entries from package.json

"@webpack-cli/serve": "^1.0.1-alpha.5",
"webpack": "^5.0.0-beta.13",
"webpack-cli": "^4.0.0-beta.8",

Steps to reproduce the behavior:

  1. Define a devServer config in your webpack config file
  2. Run webpack serve --config webpack.dev.js

Expected behavior

Previously the dev server would pick up devServer config object from your webpack config file

Additional context

If I change line 28 from startDevServer.ts it works as expected but obviously this ignores the cli overrides.

- const server = new Server(compiler, options);
+ const server = new Server(compiler, devServerOptions);

CLI output

ℹ 「wds」: Project is running at http://myreactapp.test:8080/
ℹ 「wds」: webpack output is served from /eccreactapp/dist
ℹ 「wds」: Content not from webpack is served from /path/to/my/reactapp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions