Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save federicomichela/c187150f8d2cd73f08e76836e831f716 to your computer and use it in GitHub Desktop.
Save federicomichela/c187150f8d2cd73f08e76836e831f716 to your computer and use it in GitHub Desktop.
import {createApp} from 'vue';
import App from './App.vue;
const requireComponent = require.context('./', true, /App[A-Z]\w+\.(vue/js/ts)$);
const app = createApp(App);
requireComponent.keys().forEach(filename => {
let baseComponentConfig = requireComponent(filename);
baseComponentConfig = baseComponentConfig.default || baseComponentConfig;
const baseComponentName = baseComponentConfig.name || ( fileName.replace(/^.+\//, '').replace(/\.\w+$/, ''));
app.component(baseComponentName, baseComponentConfig);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment