From 2504fff3ba484265720b5cd9b36d098017cde746 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 14 Nov 2019 13:56:53 +0300 Subject: [PATCH] make BaseComponents globally available --- webapp/nuxt.config.js | 1 + webapp/plugins/base-components.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 webapp/plugins/base-components.js diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 17bb5290c..4a35e37f4 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -107,6 +107,7 @@ export default { ** Plugins to load before mounting the App */ plugins: [ + { src: '~/plugins/base-components.js', ssr: true }, { src: `~/plugins/styleguide${process.env.STYLEGUIDE_DEV ? '-dev' : ''}.js`, ssr: true, diff --git a/webapp/plugins/base-components.js b/webapp/plugins/base-components.js new file mode 100644 index 000000000..61a18c3fa --- /dev/null +++ b/webapp/plugins/base-components.js @@ -0,0 +1,11 @@ +import Vue from 'vue' + +const componentFiles = require.context('~/components/_new/generic', true, /Base[a-zA-Z]+\.vue/) + +componentFiles.keys().forEach(fileName => { + const component = componentFiles(fileName) + const componentConfig = component.default || component + const componentName = component.name || fileName.replace(/^.+\//, '').replace('.vue', '') + + Vue.component(componentName, componentConfig) +})