const vueComponents = require.context(`@/components`, true, /index\.vue$/).keys();
const jsComponents = require.context(`@/components`, true, /index\.js$/).keys();
const components = [...vueComponents, ...jsComponents];
const modules = [];
if (components && components.length > 0) components.forEach((a, b) => {
  let module = require(`@/components/${a.split('./').join('')}`);
  if (module && module.default && module.default.name) {
    modules[b] = module.default;
  }
});

const install = Vue => modules.length > 0 && modules.forEach(a => Vue.component(a.name, a));

if (typeof window !== 'undefined' && window.Vue) install.use(Window.Vue);

export default { install };