index.js
521 Bytes
const path = require('path');
export function loadModule(module){
if(!module||!module instanceof String)return exportFunc();
let file = require(`./${module}.vue`);
return {
[module]: file.default||file
}
}
export function exportFunc(){
const files = require.context('./',false,/\.vue$/);
const modules = {};
files.keys().forEach(key=>{
let name = path.basename(key,'.vue');
modules[name] = files(key).default || files(key);
})
return modules;
}
export default exportFunc();