Skip to content

Instantly share code, notes, and snippets.

@gaganjakhotiya
Last active October 27, 2017 14:54
Show Gist options
  • Save gaganjakhotiya/d3eaa375010fca5422d172c98fc76c9d to your computer and use it in GitHub Desktop.
Save gaganjakhotiya/d3eaa375010fca5422d172c98fc76c9d to your computer and use it in GitHub Desktop.
Prepare Widget Map
const widgetMap = {}
const requireContext = require.context('../src', true, /\.widget.jsx$/)
const modulesPathList = requireContext.keys()
const widgetNameRegex = /[a-z-A-Z]+(?=\.widget\.jsx$)/
for (const path of modulesPathList) {
widgetMap[widgetNameRegex.exec(path)[0]] = requireContext(path)
}
export default widgetMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment