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

Check for Custom ENV Variable from CRA #128

Merged
merged 2 commits into from
Mar 2, 2020
Merged

Check for Custom ENV Variable from CRA #128

merged 2 commits into from
Mar 2, 2020

Conversation

wgranger
Copy link
Contributor

@wgranger wgranger commented Feb 28, 2020

This PR adds a check in the config file for an environment variable set via Create React App. This is necessary for deploying ALICE to staging.

ALICE is built using Create React App, which strictly sets NODE_ENV to production when running react-scripts build. Although you can set custom variables (like REACT_APP_ENV), you are not allowed to change the node environment (see Special Thanks on link), as it is strictly set.

You can eject Create React App to set the NODE_ENV, but this is a pretty drastic thing to do, and you lose all the convenience of having CRA handle your dependencies.

Copy link
Contributor

@eatyourgreens eatyourgreens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

lib/config.js Outdated
@@ -57,9 +57,10 @@ var statFromShell = process.env.STAT_HOST;
var oauthFromShell = process.env.OAUTH_HOST;

var envFromBrowser = locationMatch(/\W?env=(\w+)/);
const envFromCreateReactApp = process.env.REACT_APP_ENV
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using const, which doesn't follow convention (other variable declarations use the old school var) and will break web browser compatibility...

...if that web browser is Internet Explorer 10.

Wait, what am I complaining about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will make the change

@wgranger wgranger merged commit 36caa88 into master Mar 2, 2020
@wgranger wgranger deleted the add-cra-check branch March 2, 2020 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants