Skip to content

Add CLI and config option to auto assign port #1191

Closed
@robert-prib-polestar

Description

@robert-prib-polestar
  • Operating System: N/A
  • Node Version: N/A
  • NPM Version: N/A
  • webpack Version: N/A
  • webpack-dev-server Version: N/A
  • This is a bug
  • This is a feature request
  • This is a modification request

Code

Example code for port auto assign

This example script checks if the current port is in use and keeps trying attempting to start the dev server by traversing up by 1 based on the provided starting port.
https://gist.github.com/robert-prib-polestar/29cc8fab3eb83602009df3fbdb626ac4

Motivation / Use Case

  • It's useful to load multiple instances of the same project locally when you want to compare builds.
  • It's annoying to have to alter the package.json scripts to start up a new dev server with a different port.
  • Within projects, I often have multiple scripts within the package.json to start dev-servers with different environment variables and other options set. It's handy to be able to easily load up multiple dev servers without defining a specific port.

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