Skip to content

Instantly share code, notes, and snippets.

@techlab23
Created July 24, 2020 05:21
Show Gist options
  • Save techlab23/78a0893f3d86fac7bb7e7f17fe486579 to your computer and use it in GitHub Desktop.
Save techlab23/78a0893f3d86fac7bb7e7f17fe486579 to your computer and use it in GitHub Desktop.
component registration
import Vue from 'vue'
// Importing all components inside './components' folder
const req = require.context('./components/', true, /\.(js|vue)$/i);
req.keys().map(key => {
const fileNameKey = key.substr(key.lastIndexOf('/') + 1);
const name = fileNameKey.match(/\w+/)[0];
return Vue.component(name, req(key).default)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment