Forked from eirikb/load-vue-components-from-folder.js
Created
August 12, 2019 17:39
-
-
Save fabioebner/360ef5fddd1d3a80ea74289aa591ab9c to your computer and use it in GitHub Desktop.
Load all Vue components from a given folder, no need for an "index.js"-file
This file contains hidden or 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
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