Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import Vue from 'vue'
  2. import upperFirst from 'lodash/upperFirst'
  3. import camelCase from 'lodash/camelCase'
  4.  
  5. // Require in a base component context
  6. const requireComponent = require.context('.', false, /\.vue$/i)
  7.  
  8.  
  9. requireComponent.keys().forEach(fileName => {
  10. // Get component config
  11. const componentConfig = requireComponent(fileName)
  12.  
  13. // Get Pascal Case / Camel Case name of component
  14. // const componentName = upperFirst(fileName.replace(/^\. \//, '').replace(/\. \w+$/, ''))
  15.  
  16. // Skipping the Pascal / Camelcase
  17. const componentName = fileName.split('/').pop().split('.')[0]
  18.  
  19. // Registering the component globally
  20. Vue.component(componentName, componentConfig.default || componentConfig)
  21. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement