diff --git a/src/components/_globals.ts b/src/components/_globals.ts new file mode 100644 index 00000000..9ba46a5d --- /dev/null +++ b/src/components/_globals.ts @@ -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) +}) \ No newline at end of file diff --git a/src/views/loadComponents.ts b/src/views/loadComponents.ts deleted file mode 100644 index b531f205..00000000 --- a/src/views/loadComponents.ts +++ /dev/null @@ -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) - }) -}