Created
March 27, 2021 12:19
-
-
Save federicomichela/c187150f8d2cd73f08e76836e831f716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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