While I dont know the answer to your specific questions, I am wondering whether you could just include the SPAindex.html into a blade file. A simple copy paste of code. And then just use normal routing.
How to route to a custom html file in public folder?
Dear Community,
I have an SPA created outside of the Laravel framework and I built and exported the SPAindex.html so it got placed inside the Laravel public folder.
I'm trying to set this up the routing, but it's not working. This is my controller:
public function listo()
{
return \File::get(public_path() . '/SPAindex.html');
}
The files seem to get loaded when checking the network tab, but nothing is showing up... o_O
When I do valet link on the public folder and go to public.dev/SPAindex.html it shows up correctly!! But this defeats the purpose of the laravel routing I think...
Questions:
-
How should I exactly write the controller of the route in the case I want to link
public/SPAindex.html? -
My script that builds the SPA into the public folder is a custom webpack file for this SPA outside of Laravel. Do I still need to run Laravel mix for anything else?
The answer was:
return \File::get(public_path() . '/SPAindex.html');
can work perfectly, but you CANNOT delete Laravel's index.php file inside the public folder.
- Make sure you use a unique name for your main html file, like
SPAindex.htmland not useindex.html - Make sure you keep the original laravel index.php inside the public folder.
- If you still get a blank screen you need to:
php artisan cache:clearandmeta+shift+Rto force a full css refresh. (this was my problem where the files would show up in network, but i'd get a blank screen)
(BTW, no need to run laravel mix for anything)
Please or to participate in this conversation.