added check for componentsConfig to dynamic import
This commit is contained in:
parent
2b2dedcdc2
commit
9a3614da65
2 changed files with 7 additions and 3 deletions
|
@ -19,6 +19,10 @@ export const dynamicImport = (filePath) => {
|
|||
console.log('dynamicImport > filePath type:', typeof filePath);
|
||||
throw new Error('file path provided to dynamicImport() must be a string');
|
||||
}
|
||||
if (!componentsConfig) {
|
||||
console.log('no componentsConfig found in siteConfig.js');
|
||||
return require(`${filePath}`);
|
||||
}
|
||||
// split out the file folders // filter out any empty or white-space-only strings
|
||||
const folders = filePath.split('/').filter(folderName => folderName.replace(/\s/g, '').length);
|
||||
// check for the component corresponding to file path in the site config object
|
||||
|
|
|
@ -10,7 +10,7 @@ function SiteConfig () {
|
|||
this.auth = {
|
||||
sessionKey: 'default',
|
||||
};
|
||||
this.customComponents = {
|
||||
this.componentsConfig = {
|
||||
components: {},
|
||||
containers: {},
|
||||
pages : {},
|
||||
|
@ -35,13 +35,13 @@ function SiteConfig () {
|
|||
if (!config) {
|
||||
return console.log('No site config received.');
|
||||
}
|
||||
const { analytics, assetDefaults, auth, customComponents, details, publishing } = config;
|
||||
const { analytics, assetDefaults, auth, componentsConfig, details, publishing } = config;
|
||||
this.analytics = analytics;
|
||||
this.assetDefaults = assetDefaults;
|
||||
this.auth = auth;
|
||||
this.details = details;
|
||||
this.publishing = publishing;
|
||||
this.customComponents = customComponents;
|
||||
this.componentsConfig = componentsConfig;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue