Skip to content

[heft-storybook-plugin] Add --port flag to set the Storybook dev server port in serve mode#5819

Open
UberMouse wants to merge 1 commit into
microsoft:mainfrom
UberMouse:heft-storybook-plugin-port-flag
Open

[heft-storybook-plugin] Add --port flag to set the Storybook dev server port in serve mode#5819
UberMouse wants to merge 1 commit into
microsoft:mainfrom
UberMouse:heft-storybook-plugin-port-flag

Conversation

@UberMouse
Copy link
Copy Markdown
Contributor

Summary

When Heft launches Storybook in serve mode (--storybook with heft start/watch), there was previously no way to control which port the Storybook dev server binds to from the Heft command line — you were limited to Storybook's default port. This PR adds a --port parameter to the storybook parameter scope that is passed straight through to the Storybook CLI's own --port option, so the dev server can be bound to a specific port.

This is helpful in environments that pre-allocate a port before launching the dev server (for example, a build/orchestration daemon that needs to know the port up front so it can poll for readiness).

Details

The change mirrors the existing --no-open flag:

  • heft-plugin.json declares a new --port string parameter (argumentName: "PORT").
  • StorybookPlugin.ts reads it via taskSession.parameters.getStringParameter('--port'), threads it through the prepare/run options, and — only when in serve mode and a value is provided — pushes --port <value> onto the Storybook CLI args.

Notes:

  • The flag only takes effect in serve mode, consistent with --no-open and with where a dev-server port is meaningful; it has no effect on static builds.
  • Fully backwards compatible: the parameter is optional, and when omitted the Storybook invocation is unchanged.
  • No performance impact.

How it was tested

  • rushx build in heft-storybook-plugin passes (TypeScript compile + ESLint).
  • The equivalent change has been running as a local pnpm patch against the published @rushstack/heft-storybook-plugin in a downstream monorepo, where Heft invokes Storybook in serve mode with --port and the dev server binds to the requested port.

Impacted documentation

None. Only the heft-plugin.json parameter declaration changed; the options JSON schema (storybook.schema.json) and the website docs are unaffected.

…ver port in serve mode

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant