add runtime env for production enironment

This commit is contained in:
Sorrel Bri 2020-01-09 11:51:45 -08:00 committed by sorrelbri
parent 173bb8766c
commit b62458218b
3 changed files with 10 additions and 3 deletions

View file

@ -1225,6 +1225,11 @@
"@types/yargs": "^13.0.0"
}
},
"@mars/heroku-js-runtime-env": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@mars/heroku-js-runtime-env/-/heroku-js-runtime-env-3.0.2.tgz",
"integrity": "sha1-5bhIDtgrVARkdKCKE5uNlWCvOig="
},
"@mrmlnc/readdir-enhanced": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",

View file

@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@mars/heroku-js-runtime-env": "^3.0.2",
"@testing-library/user-event": "^7.1.2",
"flow-bin": "^0.114.0",
"node-sass": "^4.13.0",
@ -18,10 +19,8 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"flow": "./node_modules/.bin/flow flow",
"predeploy": "REACT_APP_ENVIRONMENT=production npm run build",
"postinstall": "react-scripts build"
},
"eslintConfig": {
"extends": "react-app"

View file

@ -1,3 +1,6 @@
import runtimeEnv from '@mars/heroku-js-runtime-env';
const env = runtimeEnv();
const production = {
apiAddress: 'https://node-go-api.herokuapp.com',
endpoint: 'https://play-node-go.herokuapp.com'
@ -8,7 +11,7 @@ const development = {
endpoint: 'http://localhost:3000'
}
const config = process.env.REACT_APP_ENVIRONMENT === 'production'
const config = env.REACT_APP_ENVIRONMENT === 'production'
? production
: development