Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Vue from 'vue'
- import { upperFirstLetter } from './utils/string.extensions'
- /** List all files from folder name. */
- let requireComponent = require.context(
- './components',
- // Consider subfolders?
- true,
- // The regular expression used to match base component filenames
- /[A-Z]\w+\.(vue|js|ts)$/
- )
- /** Iterate keys. */
- requireComponent.keys().forEach(fileName => {
- /** Require the component. */
- const componentConfig = requireComponent(fileName);
- /** Remove ./ and file extension. */
- let componentName = fileName.replace(/^\.\/(.*)\.\w+$/, '$1')
- componentName = componentName.split('/').pop() || "";
- /** Register component. */
- Vue.component(
- upperFirstLetter(componentName),
- componentConfig.default || componentConfig
- )
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement