Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wizjo's avatar
Level 26

Vite assets not served from "public/build" folder

The problem is that assets are available only when I run: npm run dev command so Vite server is up.

I expect when I build assets with command npm run build, they are published to /public/build and then without starting Vite server assets should be served from this folder, but they are not.

I found this solution:

@production
    @php
        $manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
    @endphp
    <script type="module" src="/build/{$manifest['resources/js/app.js']['file']}"></script>
    <link rel="stylesheet" href="/build/{$manifest['resources/js/app.js']['css'][0]}">
@else
    <script type="module" src="http://localhost:3000/@vite/client"></script>
    <script type="module" src="http://localhost:3000/resources/js/app.js"></script>
@endproduction

but I feel it is a bit "hacky" and maybe I am missing something. Am I?

0 likes
5 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Yeah don't use a hacky solution like that. Use the vite helper and explain the problem

One thing I often see is people still have a file named hot in the public directory. Delete this as it's a leftover from dev

3 likes
wizjo's avatar
Level 26

I use the helper:

layout/app.blade.php:

{{ @vite('resources/js/app.js') }}

After few days it worked as intended and I don`t think I changed anything related.

Sametimes I experience this kind of problems which looks like some caching issues.

Anyway, thanks for involvement.

Sinnbeck's avatar

Happy to help. Weird that it started working. Maybe the hot file wasn't deleted properly :)

dwissmann's avatar

I believe I have a very similar problem - I setup a brand new laravel - inertia - Vue environment by following all the docs, then I run npr run dev and get following: ➜ Local: ----127.0.0.1:5173/ ➜ Network: use --host to expose

LARAVEL v9.35.1 plugin v0.6.1

➜ APP_URL: ----localhost

I learned that the app werbserver isn't running so I run php artisan serve and get: php artisan serve

INFO Server running on [----127.0.0.1:8000].

I go to that URL and it serves the page without the resources - my console has following errors:

 127.0.0.1/:6 GET ----/127.0.0.1:5173/css/app.css net::ERR_ABORTED 404 (Not Found) 127.0.0.1/:7 GET ----127.0.0.1:5173/js/app.js net::ERR_ABORTED 404 (Not Found)

(---- placehodler for protocol since I can't post urls) How can I fix this without hacking my environment?

Sinnbeck's avatar

@dwissmann You need to run both servers at the same time. But if it isnt working, then copy your problem to a new thread and we will try and help you out :)

1 like

Please or to participate in this conversation.