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

Drop NODE_ENV=development when building #68

Closed
tmeasday opened this issue Dec 2, 2019 · 11 comments
Closed

Drop NODE_ENV=development when building #68

tmeasday opened this issue Dec 2, 2019 · 11 comments
Assignees
Labels
enhancement Classification: New feature or request

Comments

@tmeasday
Copy link
Member

tmeasday commented Dec 2, 2019

This is a historical accident. I'm not sure if it is a breaking change or not.

@tmeasday tmeasday added the enhancement Classification: New feature or request label Dec 2, 2019
@lifeiscontent
Copy link

@tmeasday seems in CI when chromatic is running, it doesn't include env vars. so my storybook is busted until I can figure out how to overcome this. (using next.js) in preview.js

import { setConfig } from 'next/config';

setConfig({
  publicRuntimeConfig: {
    API_HOST: process.env.API_HOST,
    GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY,
  },
});

apparently API_HOST and GOOGLE_MAPS_API_KEY are undefined when chromatic runs in CI

@tmeasday
Copy link
Member Author

tmeasday commented Jan 14, 2020

@lifeiscontent are the env vars used in the frontend (ie inside the browser)? This seems like a storybook issue perhaps, we don't drop any env vars we just add a couple: https://github.com/chromaui/chromatic-cli/blob/master/bin/storybook/start-app.js#L60:L64

You'd need to ensure you webpack config for built storybooks passes env vars through to the browser, using something like DefinePlugin I think.

@lifeiscontent
Copy link

@tmeasday thanks for the response!

We’re using next.js so in the storybook config I’m using setConfig from “next/config” and setting the env vars we need from process.env.

I’m also using a custom web pack config for storybook to step over some of the issues with next.js e.g. Babel configs

@lifeiscontent
Copy link

also, fwiw, everything works as expected in development.

@tmeasday
Copy link
Member Author

Does it work when you run yarn build-storybook though @lifeiscontent?

@lifeiscontent
Copy link

@tmeasday great question, let me try it!

@lifeiscontent
Copy link

@tmeasday yep, it builds, should I try and run it with serve?

@lifeiscontent
Copy link

@tmeasday I just ran it with serve, everything works fine.

@tmeasday
Copy link
Member Author

You don't get any errors to the console?

@lifeiscontent
Copy link

@tmeasday None!

@lifeiscontent
Copy link

@tmeasday pinged you on Intercom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Classification: New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants