Created
January 3, 2019 07:54
-
-
Save anxgang/36b93fe2888211a81dc00a2d300d0afd to your computer and use it in GitHub Desktop.
Autoload Vue Components
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
// ::Autoload Components:: | |
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).default); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment