Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Vue from 'vue'
- import upperFirst from 'lodash/upperFirst'
- import camelCase from 'lodash/camelCase'
- // Require in a base component context
- const requireComponent = require.context('.', false, /\.vue$/i)
- requireComponent.keys().forEach(fileName => {
- // Get component config
- const componentConfig = requireComponent(fileName)
- // Get Pascal Case / Camel Case name of component
- // const componentName = upperFirst(fileName.replace(/^\. \//, '').replace(/\. \w+$/, ''))
- // Skipping the Pascal / Camelcase
- const componentName = fileName.split('/').pop().split('.')[0]
- // Registering the component globally
- Vue.component(componentName, componentConfig.default || componentConfig)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement