add runtime env for production enironment

This commit is contained in:
Sorrel Bri 2020-01-09 11:51:45 -08:00
parent d8ecb3abb6
commit 82612dc555
3 changed files with 10 additions and 3 deletions

5
package-lock.json generated
View file

@ -1225,6 +1225,11 @@
"@types/yargs": "^13.0.0" "@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": { "@mrmlnc/readdir-enhanced": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",

View file

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

View file

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