Created
February 2, 2018 03:58
-
-
Save mitchell-garcia/8c2b40046d2943fe381502dee6b0fc4c to your computer and use it in GitHub Desktop.
This file contains 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 modules = {}; | |
let tmpModule; | |
function requireAll(r) { | |
r.keys().forEach(function (moduleName) { | |
tmpModule = r(moduleName); | |
if (!tmpModule.default) { | |
throw new Error(`Module not correctly exported. Excepted Vuex Module definition but got: ${tmpModule.default} for module: ${moduleName}`); | |
} | |
const fileName = moduleName.replace(/(\.\/|\.js)/g, '').split('/'); | |
const name = fileName[fileName.length - 1]; | |
modules[name] = tmpModule.default; | |
}); | |
} | |
requireAll(require.context('./directory', true, /.js$/)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment