Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] environment variables for CRA are omitted #175

Open
original001 opened this issue Nov 22, 2020 · 1 comment
Open

[Bug] environment variables for CRA are omitted #175

original001 opened this issue Nov 22, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@original001
Copy link

original001 commented Nov 22, 2020

Describe the bug

Storybook overrides environment variables defined with prefix REACT_APP. Possibly, it overrides more variables, but I don't investigate it.

Steps to reproduce the behavior

  1. Define any variable with REACT_APP prefix.
  2. Run build-storybook
  3. Open bundle in browser
  4. Find place where webpack replace process.env with variable's object.
  5. I don't see my variable in the list

Expected behavior

List of vars includes my extra REACT_APP variable

Screenshots and/or logs

image

After short investigation I found that preset override DefinePlugin of cra webpack.config in this line

Environment

  • OS: MacOS Mojave
  • Node.js version: v12.14.1
  • NPM version: 6.13.4

Details

It works if I use .env file, but doesn't if I use cli

@original001 original001 added the bug Something isn't working label Nov 22, 2020
@generalov
Copy link

This probably due to mergePlugins function implementation. The function takes the first plugin definition into results. According to the order of plugins the function takes DefinePlugin from storybook and omits the definition produced by CRA webpack config.
CleanShot 2021-01-03 at 13 01 03

Related:
storybookjs/storybook#4841
storybookjs/storybook#12270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants