Skip to content

Commit

Permalink
Get dynamic config from process.env.REACT_SERVER_CONFIG_SOURCE
Browse files Browse the repository at this point in the history
  • Loading branch information
mocheng committed Feb 13, 2017
1 parent 9611f41 commit 193bf29
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/react-server/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ if (SERVER_SIDE) {
module.exports = function () {
// only read out the config once, and then cache it. -sra.
if (null === config) {
/*eslint-disable no-process-env */
if (process.env.REACT_SERVER_CONFIGS) {

//eslint-disable-next-line no-process-env
if (process.env.REACT_SERVER_CONFIG_SOURCE) {
var path = require('path');
//eslint-disable-next-line no-process-env
config = require(path.join(process.cwd(), process.env.REACT_SERVER_CONFIG_SOURCE));
}
//eslint-disable-next-line no-process-env
else if (process.env.REACT_SERVER_CONFIGS) {
var fs = require("fs");
/*eslint-disable no-process-env */
//eslint-disable-next-line no-process-env
var configFile = fs.readFileSync(process.env.REACT_SERVER_CONFIGS + "/config.json");
/*eslint-disable no-process-env */
config = Object.freeze(JSON.parse(configFile));
} else {
config = Object.freeze({});
Expand Down

0 comments on commit 193bf29

Please sign in to comment.