Skip to content

Conversation

@JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Dec 17, 2025

What I did

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

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

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
    • Updated environment variable configuration during the build process for improved consistency and maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@JReinhold JReinhold self-assigned this Dec 17, 2025
@JReinhold JReinhold added bug patch:yes Bugfix & documentation PR that need to be picked to main branch core builder-webpack5 ci:docs Run the CI jobs for documentation checks only. labels Dec 17, 2025
@JReinhold JReinhold changed the title Core: Fix .env.-file parsing Core: Fix .env-file parsing Dec 17, 2025
@JReinhold JReinhold merged commit 35bd9a2 into next Dec 17, 2025
135 of 140 checks passed
@JReinhold JReinhold deleted the jeppe/fix-env-var-2 branch December 17, 2025 13:10
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Injects an explicit 'process.env' object into DefinePlugin in the webpack preview config and refactors env utilities to build a single consolidated raw env from base defaults, dotenv/process.env merge, filtered STORYBOOK_ entries, and normalized NODE_PATH, with simplified stringification.

Changes

Cohort / File(s) Summary
Webpack preview DefinePlugin change
code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts
Adds a DefinePlugin option entry 'process.env': (${JSON.stringify(envs)}) alongside existing serialized env mappings, explicitly injecting the entire envs object under process.env.
Environment utilities refactor
code/core/src/common/utils/envs.ts
Replaces multi-step env construction with baseEnv, merges dotenv/process.env via getEnvironment(...), extracts STORYBOOK_ keys into envEntries, composes a single raw (base + envEntries), normalizes NODE_PATH with nodePathsToArray, and derives stringified directly from raw; removes fullRaw and prior process.env workaround.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify merge order and precedence between baseEnv, dotenv (getEnvironment(...)), and process.env.
  • Confirm STORYBOOK_ key filtering produces the expected keys/values in raw.
  • Check NODE_PATH normalization and any module resolution implications.
  • Ensure the added 'process.env' DefinePlugin entry doesn't conflict with other DefinePlugin entries or runtime assumptions.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9a2a5 and 1cbf505.

📒 Files selected for processing (2)
  • code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts (1 hunks)
  • code/core/src/common/utils/envs.ts (2 hunks)

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

ndelangen pushed a commit that referenced this pull request Dec 17, 2025
Core: Fix `.env`-file parsing
(cherry picked from commit 35bd9a2)
@github-actions github-actions bot mentioned this pull request Dec 17, 2025
7 tasks
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug builder-webpack5 ci:docs Run the CI jobs for documentation checks only. core 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.

2 participants