vite-plugin: Asset files are not loading after a fresh Laravel Sail installation on MacOS
- Laravel Vite Plugin Version: 0.2.4
- Laravel Version: 9.19.0
- Node Version: 16.15.1
- NPM Version: 8.12.1
Description:
After a fresh installation of Laravel Sail and Laravel Breeze, css and js files are not loading in the browser
Steps To Reproduce:
curl -s "https://laravel.build/example-app" | bash
cd example-app
./vendor/bin/sail up
sail composer require laravel/breeze
sail artisan breeze:install
sail npm install && sail npm run dev
vite v2.9.13 dev server running at:
Local: http://localhost:5173/ Network: http://192.168.48.4:5173/
When I visit localhost/login, the console shows “Failed to load resource: bad URL” and these are the locations where the browser is looking for the resources:
http://0.0.0.0:5173/resources/css/app.css http://0.0.0.0:5173/@vite/client http://0.0.0.0:5173/resources/js/app.js
This is how the login page looks like
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (5 by maintainers)
@AdyGCode Thanks for the reply. I tried all the suggestions:
sail down
andsail up
,Ctr
+C
,sail npm update
, clearing cache from safari and from artisan. Nothing seems to work in my case. As a last resort, I’ll try to get a hold of a different Mac and try to run a fresh install there to see how it goes.Btw, your reply made me think of this immortal line 🤣
@AdyGCode @Fedeorlandau Accessing the Vite dev server directly (http://localhost:3000 or http://localhost:5173, depending on whether you’re running it inside Sail) is expected to return a blank screen at the moment as that’s just where Vite serves assets for HMR. This has been improved with #57 as we’ll now be outputting a default help screen to instruct users to run a dev server for Laravel.
That happens, and given my configuration is a bit wild, I was wondering the same.
If you get the chance to re-build the Mini then you may find it clears up the issue. If not it, you have your answer for now.
@timacdonald and @tuto1902 - No problems closing, but it may be worth adding a note that in some situations, the HMR option under server may be required.
Ok, so I think this is just a problem with my Mac mini, or the Mac OS version, or the version of Safari, or maybe an ancient curse passed down by generations… In any case, I just ran my own steps to reproduce in an old MacBook Air with Mac OS Big Sur and sure enough, everything worked fine out of the box.
@timacdonald if there’s no objection from anyone else, I think we can close this issue. 🤷🏻♂️
Hi @timacdonald,
I’m getting very similar issues to the other users, and I’m running on an Intel Mac, with Docker Desktop 4.10+
As I prefer to use MariaDB over MySQL, I used the steps:
The
vite.config.js
file reads:Docker compose file
docker-compose.yml
has the lines:Tested using Chrome, Safari, Edge and Firefox.
http://localhost:5173
http://localhost
http://localhost/register
On everything except Safari, I’ve managed to view the content as it should be for the default layout.
I use multiple browsers for testing to make sure that things are as I expect, so the fact that Safari is failing for some reason is a mild concern.
More of a concern is also that the
http://localhost:5173/
is not rendering anything.I have had no problems in the past with Mix.