stencil-cli icon indicating copy to clipboard operation
stencil-cli copied to clipboard

feat: add --serverHost CLI option for configurable dev server hostname

Open marcos-hairpieces opened this issue 4 months ago • 0 comments

  • Add --serverHost option to stencil start command with localhost default
  • Support STENCIL_SERVER_HOST environment variable in server config
  • Pass serverHost through BrowserSync and renderer plugin configuration
  • Maintains backward compatibility with existing localhost behavior
  • Enables easier Docker configuration without disrupting defaults

What?

This pull request adds a new --serverHost CLI option to the stencil start command that allows developers to specify a custom hostname for the development server. The feature also supports configuration via the STENCIL_SERVER_HOST environment variable. This enhancement maintains full backward compatibility by defaulting to localhost when no custom host is specified.

The implementation propagates the serverHost configuration through the entire application stack:

  • CLI argument parsing and validation
  • BrowserSync proxy and host configuration
  • Server configuration via environment variable
  • Renderer plugin options for proper URL generation

This change is particularly valuable for Docker-based development environments where binding to 0.0.0.0 or a specific hostname is required for proper container networking, while preserving the existing localhost behavior for traditional development setups.

Tickets / Documentation

  • issue regarding the addition of this feature
  • README.md#running-in-docker provides some steps on how to run stencil in docker, I've tried following those on both WSL and Linux with no success because of the lack of this feature, after patching it with this feature it worked(perhaps I was missing something and if that is the case I would really like to know)

Screenshots (if appropriate)

N/A - This is a CLI configuration enhancement without visual changes.

cc @bigcommerce/storefront-team

marcos-hairpieces avatar Oct 31 '25 16:10 marcos-hairpieces