0๐
I tried this way also but is not making use of defineAsyncComponent ๐
app.js file content:
import './bootstrap';
import { createApp } from 'vue';
import { defineAsyncComponent } from 'vue'
const app = createApp({});
let index = 0;
const components = []
Object.entries(import.meta.glob('./**/*.vue', { eager: true })).forEach(([path, definition]) => {
index++
var module_name = path.split('/').pop().replace(/\.\w+$/, '')
const camelToDashed = module_name.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`).slice(1);
components[index] = defineAsyncComponent( () => import('./components/'+camelToDashed+'.vue') )
app.component(path.split('/').pop().replace(/\.\w+$/, ''), definition.default)
});
app.mount('#app');
Source:stackexchange.com