Created
July 9, 2019 14:33
-
-
Save daniepetrov/14b28f11ed7ee49a1e6063b245c78e6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 envConfig = { | |
development: { | |
SITE_URL: 'http://localhost:3000', | |
API_URL: 'http://localhost:3000/api' | |
}, | |
testing: { | |
SITE_URL: 'https://test.site.com', | |
API_URL: 'https://api.test.site.com' | |
}, | |
production: { | |
SITE_URL: 'https://site.com', | |
API_URL: 'https://api.site.com' | |
} | |
} | |
const currentEnv = process.env.NODE_ENV | |
export default envConfig[currentEnv] | |
/* | |
---- USE IN COMPONENETS JS ---- | |
import env from './env' | |
console.log(env.SITE_URL) | |
*/ | |
/* | |
---- RUN SCRIPTS (package.json) ---- | |
... | |
"scripts": { | |
"dev": "NODE_ENV=development ...", | |
"testing": "NODE_ENV=testing ...", | |
"build": "NODE_ENV=production ...", | |
}, | |
... | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment