Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brucewu16899/efbdf90aceedb45c8412da3a598737bf to your computer and use it in GitHub Desktop.
Save brucewu16899/efbdf90aceedb45c8412da3a598737bf to your computer and use it in GitHub Desktop.
Load all Vue components from a given folder, no need for an "index.js"-file
const req = require.context('./components/', true, /\.(js|vue)$/i);
req.keys().map(key => {
const name = key.match(/\w+/)[0];
return Vue.component(name, req(key))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment