From 6269d07d01f757806b0ec6c265501cca21041f87 Mon Sep 17 00:00:00 2001 From: kPherox Date: Tue, 9 Apr 2019 21:40:23 +0900 Subject: [PATCH] Mive views/loadComponents to components/_globals --- src/components/_globals.ts | 21 +++++++++++++++++++++ src/views/loadComponents.ts | 23 ----------------------- 2 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 src/components/_globals.ts delete mode 100644 src/views/loadComponents.ts 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) - }) -}