Mive views/loadComponents to components/_globals

This commit is contained in:
kPherox 2019-04-09 21:40:23 +09:00
parent 9792439b13
commit 6269d07d01
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 21 additions and 23 deletions

View File

@ -0,0 +1,21 @@
'use strict'
import Vue from 'vue';
import { upperFirst } from 'lodash'
import { camelCase } from 'lodash'
const requireComponent = require.context(
'./globals',
false,
/Base[A-Z]\w+\.(vue|js)$/
)
requireComponent.keys().forEach((fileName: string) => {
const componentConfig = requireComponent(fileName)
const componentName = upperFirst(
camelCase(
fileName.replace(/^\.\/(.*)\.\w+$/, '$1')
)
)
Vue.component(componentName, componentConfig.default || componentConfig)
})

View File

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