Create base components loader

This commit is contained in:
kPherox 2019-04-08 05:08:14 +09:00
parent 1ef087740f
commit 94ee722245
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -0,0 +1,27 @@
'use strict'
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = require.context(
'@/components',
false,
/Base[A-Z]\w+\.(vue|js)$/
)
export default function(Vue) {
requireComponent.keys().forEach(fileName => {
const componentConfig = requireComponent(fileName)
const componentName = upperFirst(
camelCase(fileName
.split('/')
.pop()
.replace(/\.\w+$/, '')
)
)
Vue.component(componentName, componentConfig.default || componentConfig)
})
}