Skip to content

Instantly share code, notes, and snippets.

@asd1245dss
Created February 22, 2021 00:59
Show Gist options
  • Save asd1245dss/3be0ef72d2a878d010a3604bc55683ca to your computer and use it in GitHub Desktop.
Save asd1245dss/3be0ef72d2a878d010a3604bc55683ca to your computer and use it in GitHub Desktop.
Atlas external js config
define([
'./config/app',
'./config/terms-and-conditions',
'lodash',
], function (app, termsAndConditions, localConfig, gisConfig, lodash) {
if (JSON.stringify(localConfig) == JSON.stringify({})) {
console.warn('Local configuration not found. Using default values. To use a local configuration and suppress 404 errors, create a file called config-local.js under the /js directory');
}
const configs = [app,
termsAndConditions,
localConfig,
gisConfig,
]
const config = configs.reduce((accumulator, currentValue) => _.mergeWith(accumulator, currentValue, customizer));
function customizer(objValue, srcValue, key) {
if (key === 'externalLibraries' && _.isArray(objValue)) {
return objValue.concat(srcValue);
}
if (key === 'authProviders' && _.isArray(srcValue)) {
return srcValue;
}
};
config.webAPIRoot = config.api.url;
return config;
});
define([
'./config/app',
'./config/terms-and-conditions',
'lodash',
], function (app, termsAndConditions, localConfig, gisConfig, lodash) {
if (JSON.stringify(localConfig) == JSON.stringify({})) {
console.warn('Local configuration not found. Using default values. To use a local configuration and suppress 404 errors, create a file called config-local.js under the /js directory');
}
const configs = [app,
termsAndConditions,
localConfig,
gisConfig,
]
const config = configs.reduce((accumulator, currentValue) => _.mergeWith(accumulator, currentValue, customizer));
function customizer(objValue, srcValue, key) {
if (key === 'externalLibraries' && _.isArray(objValue)) {
return objValue.concat(srcValue);
}
if (key === 'authProviders' && _.isArray(srcValue)) {
return srcValue;
}
};
config.webAPIRoot = config.api.url;
return config;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment