-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Easily share environment variables with Create React App #4841
Comments
@igor-dv this is an interesting thing for presets / unified config |
@chrbala this is a great feature. I'd like us to figure out a principled way to implement it so that we can easily do this for whatever framework we're integrating with. @igor-dv's been hard at work implementing the concept of "presets" for babel/webpack config which is a real painpoint. I think once that gets worked out (over the next month or so?) this would be a nice addition to |
Sounds great, thank you! |
Extending presets to the |
Any update on this? Thanks. |
@LaurenceRolandJames I can see that @shilman has added this to the next milestone, which is great. @shilman would you like me to pick this one up? |
@mrmckeb That would be awesome! 🙇 |
I'll try to get this into #7221 as well. I think that's the best path forward here. |
This doesn't seem to be working with:
The moment I add that preset, the build breaks because now webpack can't understand CSS files. It seems the loaders are loaded incorrectly. |
Why it is like this in the first place? Why only allow STORYBOOK variables and not the rest? But then still load a default .env file (https://github.com/storybookjs/storybook/blob/next/lib/core/src/server/config/utils.js#L39). It seems this filtering could be removed and leave it to the developer. When this was added there was no discussion about it, just accepted: #1474, It is possible to revisit this decision? |
Hi @montogeek, can you raise an issue here? https://github.com/storybookjs/presets I'll then take a look at this alongside the preset. I can take a look this weekend ;) |
Is this fixed? Closing and I'm sure somebody will holler if it's not 😁 |
It definitely should be! Thanks @shilman! |
Possible regression? I just added Storybook to a new CRA app with: npx -p @storybook/cli sb init --type react_scripts An environment variable Package.json has:
I do not have this problem with an earlier version of Storybook:
It's entirely possible that I've misconfigured something, looks like Storybook has changed a bit since 5.2.4. |
We're having the same problem in #12270. Please re-open! |
@niksauer please try using the |
Is your feature request related to a problem? Please describe.
React Storybook and Create React App both require a prefix in environment variables. This makes environment switches cumbersome because both prefixes have to be defined and checked.
For example
.env
Then later you have to check both the STORYBOOK prefixed and the REACT_APP prefixed endpoints.
Describe the solution you'd like
Allow REACT_APP prefixed environment variables - it may be good to make it opt in, because it's otherwise possible to leak information that people did not intend to be in production storybook builds.
Describe alternatives you've considered
It's probably possible to do this manually with webpack overrides, but this seems like a common use case.
Are you able to assist bring the feature to reality?
Looks like it would be a one line change, though I'm not sure exactly how we'd make it opt-in.
https://github.com/storybooks/storybook/blob/4da246bbe9413510b48d1ab8b9faf4fae4656d92/lib/core/src/server/config/utils.js#L29
The text was updated successfully, but these errors were encountered: