serve does not work with multi-server
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.6k
- Forks
- 678
- Avg merge
- 17h 42m
- Merged PRs (30d)
- 17
Description
Describe the bug
We're having issues updating to webpack 5 and webpack serve. Our project is divided into multiple webpack configurations. Say for example we have one configuration for a SPA /login/ , /portal/, our application for end users and /admin/ for our administrators. We do this, so that every SPA when hosted belongs into its own folder and we can easily make sure that critical code like in our /admin/ SPA is never served outside of intranet. Now to test locally, we use webpack-dev-server's multi project configuration. Every SPA is identifiable by an unique publicPath (e. g. /admin). This worked beautifully with webpack-dev-server, but with webpack 5 and webpack-cli this is no longer the case. We use multiple webpack configurations to test our
We used to use webpack-dev-server to start our development server directly, however as I understand that is no longer working with webpack 5.
What is the current behavior?
Webpack-cli outputs a an error message:
Error: Unique ports must be specified for each devServer option inyour webpack configuration. Alternatively, run only 1 devServer config using the--config-name flag to specify your desired config.
at Object.startDevServer [as default]
To Reproduce
Steps to reproduce the behavior:
https://github.com/webpack/webpack-cli/blob/master/test/serve/basic/multi-dev-server.config.js without the explicit ports does show my use case perfectly.
Expected behavior
If publicPaths for configurations are unique, webpack serve should be able to serve them from the same port.
Screenshots
Please paste the results of webpack-cli info here, and mention other relevant information
Additional context
Maybe this was first introduced with https://github.com/webpack/webpack-cli/pull/1649 A possible solution might be to change https://github.com/webpack/webpack-cli/blob/ec3baa84479984921e40cd7113e4ab6a14723a7a/packages/serve/src/startDevServer.ts#L14 to add an additional check for unique publicPaths if ports are not unique.
Thanks a lot,
Christian
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/serve/src/startDevServer.ts and the reproduction at test/serve/basic/multi-dev-server.config.js. Run the multi-server case without explicit ports, then inspect how the CLI validates devServer options. Done means configurations with unique publicPaths can be served from one port without the unique-port error, with coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100