I'm using Laravel + Inertia + VueJS + Vite.
I did some research and it seems many people have different variations of this error, but none of the answers seem convincing enough or apply to my problem.
The error :
Unable to locate file in Vite manifest: resources/js/Pages/MainPage.vue.
Preface :
As with other people, everything works correctly and as expected when running npm run dev
, but after building the files for production using npm run build
, the error occurs.
Code :
In the head of my app.blade.php :
@routes
@vite(['resources/js/app.ts', "resources/js/Pages/{$page['component']}.vue"])
@inertiaHead
Details :
4.0.0
APP_ENV=production
in .env
If you need any more details, feel free to ask.
What I tried :
"resources/js/Pages/{$page['component']}.vue"
from app.blade.php
, but that just invites other problems : I can see in the network tab of DevTools that /build/assets/app-3c9a2cd6.js
and /build/assets/MainPage-0889c7a1.js
are being served correctly but they don't seem to be mounting (I put console.log
in the setup
function inside app.ts
but it's not doing anything, same thing for MainPage.vue
). I therefore think deleting "resources/js/Pages/{$page['component']}.vue"
is not the way to go, I could be wrong...I don't know if this qualifies as an answer but after a few months of ignoring the problem until I no longer could, I resolved it by using the following hacky and desperate method :
Now here comes the hacky part to preserve git history from the old project :
Like I said, this isn't a real 'solution', but it got my project working in the end and that's what ultimately matters so I'm putting it here in case it helps anyone who comes across this thread.
Fair warning though, this will probably take a full day of work to do correctly...