Created
December 30, 2019 18:16
-
-
Save jsphstls/71d4cffd74ebfc31877fd802bbca3095 to your computer and use it in GitHub Desktop.
Environment Based Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SOME_KEY = 'someOption' | |
const something = { | |
development: { | |
[SOME_KEY]: 'for dev' | |
}, | |
production: { | |
[SOME_KEY]: 'for prod' | |
}, | |
test: { | |
[SOME_KEY]: 'for test' | |
} | |
} | |
module.exports = something[process.env.NODE_ENV] | |
// Usage: import { someOption } from 'config.js' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each React package in a monorepo could have its own
.env.*
file that usesREACT_APP_
variables, but dependency env variables are overwritten when the dependency is imported. See more here: facebook/create-react-app#4654Instead, a different set of variables will be provided based on the NODE_ENV. This also helps align multiple packages that connect to the same service while reducing the number of ENV files.