I assume this is for inertia? It's part of the laravel vite plugin
Jul 23, 2022
4
Level 3
vite dynamic components import
Hello everyone,
I am migrating an existing laravel ineria from mix to vit.
I did all the steps in the migration guid and everything works fine except for one thing.
I have a component receives a prop conatains an array of components.
I used to require them like this (inside a loop)
....
this.$options.components[component_name] = require(`@/Pages/Components/Inputs/${component_name}`).default
....
this wont wok with vite because of "require"
so I tried these ways and none of them works
this.$options.components[component_name] = () => resolvePageComponent(`./Pages/Components/Inputs/${component_name}.vue`, import.meta.glob('./Pages/**/*.vue'))
this.$options.components[component_name] = () => resolvePageComponent(`@/Pages/Components/Inputs/${component_name}.vue`, import.meta.glob('./Pages/**/*.vue'))
this.$options.components[component_name] = resolvePageComponent(`./Pages/Components/Inputs/${component_name}.vue`, import.meta.glob('./Pages/**/*.vue'))
this.$options.components[component_name] = resolvePageComponent(`@/Pages/Components/Inputs/${component_name}.vue`, import.meta.glob('./Pages/**/*.vue'))
all of them throws the same exception
"Uncaught (in promise) Error: Page not found: ./Pages/Components/Inputs/Text.vue".
Please or to participate in this conversation.