Last active
October 27, 2017 14:54
-
-
Save gaganjakhotiya/d3eaa375010fca5422d172c98fc76c9d to your computer and use it in GitHub Desktop.
Prepare Widget Map
This file contains hidden or 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
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