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
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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?
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
Please or to participate in this conversation.