From 3e10f1a03ce70bea0f2a47442ca56fe0df9d9433 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Thu, 9 Jan 2020 11:51:45 -0800 Subject: [PATCH] add runtime env for production enironment --- packages/play-node-go/package-lock.json | 5 +++++ packages/play-node-go/package.json | 3 +-- packages/play-node-go/src/config.js | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/play-node-go/package-lock.json b/packages/play-node-go/package-lock.json index 09e7f53..29ae2eb 100644 --- a/packages/play-node-go/package-lock.json +++ b/packages/play-node-go/package-lock.json @@ -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", diff --git a/packages/play-node-go/package.json b/packages/play-node-go/package.json index 1b1fb75..07405be 100644 --- a/packages/play-node-go/package.json +++ b/packages/play-node-go/package.json @@ -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" diff --git a/packages/play-node-go/src/config.js b/packages/play-node-go/src/config.js index d66b7f6..2ce08ea 100644 --- a/packages/play-node-go/src/config.js +++ b/packages/play-node-go/src/config.js @@ -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