Created
July 26, 2019 07:22
-
-
Save jcricaro/1896acbcf00a0859af82b269617cf770 to your computer and use it in GitHub Desktop.
Component Registration
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
import Vue from 'vuex' | |
import upperFirst from 'lodash/upperFirst' | |
import camelCase from 'lodash/camelCase' | |
const requireComponent = require.context( | |
'.', false, /base-[\w-]+\.vue$/ | |
) | |
requireComponent.keys().forEach(filename => { | |
const componentConfig = requireComponent(filename) | |
const componentName = upperFirst( | |
camelCase(fileName.replace(/^\.\//, '').replace(/\.\w+$/, '')) | |
) | |
Vue.component(componentName, componentConfig.default || componentConfig) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment