-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from rocjs/fix/pre-transpile-universal-config
fix(roc-package-web-app-react): Pre-transpile universal-config
- Loading branch information
Showing
2 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
26 changes: 1 addition & 25 deletions
26
packages/roc-package-web-app-react/app/shared/universal-config.js
100755 → 100644
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1 @@ | ||
/* globals window */ | ||
/** | ||
* Universal Configuration Manager | ||
* | ||
* Manages both __application__ configuration and __Roc__ configuration. | ||
* On the server the configurations will be fetched directly and on the client it's expected that the configuration | ||
* is available on `window` as `ROC_CONFIG` and `APP_CONFIG`. | ||
* | ||
* appConfig will only contain what has been selected by `runtime.configWhitelistProperty`. That means if you want | ||
* to read the full configuration on the server you will need to read it directly from node-config. | ||
*/ | ||
|
||
export const rocConfig = (function getRocConfig() { | ||
return typeof window !== 'undefined' ? window.ROC_CONFIG : require('roc').getSettings(); // eslint-disable-line | ||
}()); | ||
|
||
const whiteListed = () => ( | ||
rocConfig.runtime.configWhitelistProperty ? | ||
require('config')[rocConfig.runtime.configWhitelistProperty] : // eslint-disable-line | ||
undefined | ||
); | ||
|
||
export const appConfig = (function getAppConfig() { | ||
return typeof window !== 'undefined' ? window.APP_CONFIG : whiteListed(); | ||
}()); | ||
module.exports = require('../../lib/app/shared/universal-config'); |
25 changes: 25 additions & 0 deletions
25
packages/roc-package-web-app-react/src/app/shared/universal-config.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* globals window */ | ||
/** | ||
* Universal Configuration Manager | ||
* | ||
* Manages both __application__ configuration and __Roc__ configuration. | ||
* On the server the configurations will be fetched directly and on the client it's expected that the configuration | ||
* is available on `window` as `ROC_CONFIG` and `APP_CONFIG`. | ||
* | ||
* appConfig will only contain what has been selected by `runtime.configWhitelistProperty`. That means if you want | ||
* to read the full configuration on the server you will need to read it directly from node-config. | ||
*/ | ||
|
||
export const rocConfig = (function getRocConfig() { | ||
return typeof window !== 'undefined' ? window.ROC_CONFIG : require('roc').getSettings(); // eslint-disable-line | ||
}()); | ||
|
||
const whiteListed = () => ( | ||
rocConfig.runtime.configWhitelistProperty ? | ||
require('config')[rocConfig.runtime.configWhitelistProperty] : // eslint-disable-line | ||
undefined | ||
); | ||
|
||
export const appConfig = (function getAppConfig() { | ||
return typeof window !== 'undefined' ? window.APP_CONFIG : whiteListed(); | ||
}()); |