Skip to content

Instantly share code, notes, and snippets.

@Splinterjke
Created January 4, 2019 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Splinterjke/17838ba92d20e944e122c9b527cf0725 to your computer and use it in GitHub Desktop.
Save Splinterjke/17838ba92d20e944e122c9b527cf0725 to your computer and use it in GitHub Desktop.
import Vue from 'vue';
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';
const requireComponent = require.context('@/components', true, /\.vue$/);
requireComponent.keys().forEach(fileName => {
const componentConfig = requireComponent(fileName);
const componentName = upperFirst(camelCase(fileName.replace(/^\.\//, '').replace(/\.\w+$/, '')));
Vue.component(componentName, componentConfig.default || componentConfig);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment