Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
const allContentPages = getAllContentPages(sections)
// Nothing to show in the style guide
const welcomeScreen = allContentPages.length === 0 && allComponentFiles.length === 0
const patterns = welcomeScreen ? getComponentPatternsFromSections(config.sections) : undefined
const renderRootJsx = config.renderRootJsx ? requireIt(config.renderRootJsx) : undefined
logger.debug('Loading components:\n' + allComponentFiles.join('\n'))
// Setup Webpack context dependencies to enable hot reload when adding new files
if (config.contextDependencies) {
config.contextDependencies.forEach((dir: string) => this.addContextDependency(dir))
} else if (allComponentFiles.length > 0) {
// Use common parent directory of all components as a context
this.addContextDependency(commonDir(allComponentFiles))
}
const styleguide = {
config: pick(config, CLIENT_CONFIG_OPTIONS),
welcomeScreen,
patterns,
sections,
renderRootJsx
}
return `
if (module.hot) {
module.hot.accept([])
}
module.exports = ${generate(toAst(styleguide))}