-
Notifications
You must be signed in to change notification settings - Fork 72
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
Force NODE_ENV=production
for Storybook builds through the CLI
#865
Force NODE_ENV=production
for Storybook builds through the CLI
#865
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this should be the default behavior? If so then I think this change is okay as-is and we should to a major version bump. Otherwise we should make it opt-in via an option (e.g. forceProductionBuild
).
Yes, I do think it should be the default (I'm not aware of any circumstances when you wouldn't want this). I'll leave it to you to do the major merge? |
NODE_ENV=production
for Storybook builds through the CLI
🚀 PR was released in |
We are using the github action to release stories that include interactions. We set
Is using |
Hi @isweetland thanks for bringing this up. I wasn't aware of the need to do this. Certainly using testing library is possible with the standard production builds but maybe there some patterns we aren't aware of! Can you post a snippet of code that triggers this? |
Thanks @isweetland, I'm not seeing the behaviour though. Can you give a couple more details (or post a SB reproduction)? What I did:
|
@tmeasday yes, I just built in a fresh sandbox and observed the same. I think I might have found the issue thanks to this comment. It seems like we're importing Being mindful about these imports seems to fix this! We'll resolve the problem and then update to Thanks! |
OK cool! Well we can always add the ability to force a different node env somehow, but it seems like something that's better avoided entirely. |
Sorry, I'm not sure what the correct forum to discuss this is. What is the reasoning behind saying "There's no reason to build in dev"? We always build our chromatic builds in dev, as we don't need to use our production webpack settings for storybook. Forcing us to build in production also throws errors for us, because it looks like we have devDependencies in our webpack build and they're missing when storybook tries to run - I'm not sure why storybook doesn't install all devDependencies. |
@brett-east this seems like a fine place to discuss it.
You missed the key "AFAIK" from the end of that :) Just that in my experience folks are building their Storybooks to be deployed to the internet so the same production considerations (like minimizations etc) apply. I wasn't aware of any situations where you wouldn't want that.
So how do you go about that? Do you set the env var in the Just trying to figure out what the best way for us to supply an escape hatch here is. As an aside in the short term, you can just build your Storybook in a separate step to Chromatic and pass it with the
Sounds like maybe your CI script is doing something odd there in terms of the dependencies it installs before running Chromatic? |
Hi @tmeasday I've spend a few hours today trying to understand why I start getting errors on Chromatic. Thanks to Carmen from the support, I got here. We always build Storybook in the dev mode, and push it to Chromatic:
We use Relay test library to mock GraphQl requests, and obviously, it doesn't work in the production mode. (Who ever would want to keep it enabled in the prod, right?). Now I have a strange situation with Chromatic. My builds don't work, and no screenshots and etc. Although my static versions of Storybooks work well (on Chromatic also). How can I fix it? Can you enable dev mode somehow? Do I need to create a new issue for that, or it's possible to reopen this one? |
It seems this can get set to
development
when builds are spawned from the Visual Tests addon. There's no reason to build in dev, AFAIK.I guess technically this might be a breaking change, not sure.
📦 Published PR as canary version:
9.1.1--canary.865.7041382024.0
✨ Test out this PR locally via: