Skip to content

CLI: Set STORYBOOK environment variable#33938

Merged
yannbf merged 1 commit into
nextfrom
yann/add-storybook-to-process-env
Feb 26, 2026
Merged

CLI: Set STORYBOOK environment variable#33938
yannbf merged 1 commit into
nextfrom
yann/add-storybook-to-process-env

Conversation

@yannbf
Copy link
Copy Markdown
Member

@yannbf yannbf commented Feb 25, 2026

Closes #

What I did

This PR introduces an environment variable process.env.STORYBOOK to be accessed by any integrator that needs it at runtime in node. One use case is Vike, where it needs to know when to not include certain vite plugins and validations that would clash when ran in Storybook.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Run a sandbox for template, e.g. yarn task --task sandbox --start-from auto --template react-vite/default-ts
  2. Write process.env.STORYBOOK in main.js
  3. Run Storybook dev or build and see that it exists

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Chores
    • Added environment configuration flag to support development tooling integration during application startup.

@yannbf yannbf added feature request cli patch:yes Bugfix & documentation PR that need to be picked to main branch ci:normal labels Feb 25, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 25, 2026

View your CI Pipeline Execution ↗ for commit 3d39c26

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ❌ Failed 9m 33s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-25 18:38:13 UTC

@brillout
Copy link
Copy Markdown

I can confirm this is needed for a seamless Storybook with Vike integration (import.meta.env isn't available because Vike's code is ssr.external).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a47ef9 and 3d39c26.

📒 Files selected for processing (1)
  • code/core/src/bin/core.ts

📝 Walkthrough

Walkthrough

Added an environment variable initialization in the core startup sequence. The STORYBOOK environment variable is set to 'true' immediately after establishing the CLI version in the global context, enabling environment-based behavior for subsequent operations.

Changes

Cohort / File(s) Summary
Environment Setup
code/core/src/bin/core.ts
Added initialization of STORYBOOK environment variable to 'true' at startup, placed after cliVersion establishment in global context.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@yannbf yannbf merged commit 090474e into next Feb 26, 2026
123 of 135 checks passed
@yannbf yannbf deleted the yann/add-storybook-to-process-env branch February 26, 2026 13:21
yannbf added a commit that referenced this pull request Mar 2, 2026
…ess-env

CLI: Set STORYBOOK environment variable
(cherry picked from commit 090474e)
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Mar 2, 2026
@yannbf yannbf added the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Mar 10, 2026
@Sidnioulz
Copy link
Copy Markdown
Member

✔️ QA ok

@Sidnioulz Sidnioulz removed the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal cli feature request patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants