Created
July 24, 2020 05:21
-
-
Save techlab23/78a0893f3d86fac7bb7e7f17fe486579 to your computer and use it in GitHub Desktop.
component registration
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
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