Skip to content

Instantly share code, notes, and snippets.

@aprilandjan
Last active April 19, 2017 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprilandjan/aed42a64aa5da4d23aa8747fc2e3b4b8 to your computer and use it in GitHub Desktop.
Save aprilandjan/aed42a64aa5da4d23aa8747fc2e3b4b8 to your computer and use it in GitHub Desktop.
function requireAll(requireContext) {
var result = {}
requireContext.keys().forEach(path => {
var name = path.replace(/^.*(\\|\/|\:)/, '').split('.')[0]
result[name] = requireContext(path)
})
return result
}
var modules = requireAll(require.context("./api", false, /^\.\/.*\.js$/))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment