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

madprabh's avatar

Vite

Hey everyone,

Running into a strange problem. I am using Jetstream for one of my projects which uses vite to compile assets. When I checked inertia component the version was returning null.

When I set ASSET_URL in .env file I started getting the version but it doesn't change even when there is a change in my front end asset.

I saw in the vite document that it suggested me to do this

public function version(Request $request): ?string
{
    return vite()->getHash();
}

but when I do this it throws an error

Call to undefined function App\Http\Middleware\vite()

Anyone have any ideas where I am going wrong?

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

This is how I do it in my project

    public function version(Request $request)
    {
        if (file_exists($manifest = public_path('build/manifest.json'))) {
            return md5_file($manifest);
        }
    }

Remember to run npm run build to create the file

Sinnbeck's avatar

This is the official one btw.

    public function version(Request $request)
    {
        if (config('app.asset_url')) {
            return md5(config('app.asset_url'));
        }

        if (file_exists($manifest = public_path('mix-manifest.json'))) {
            return md5_file($manifest);
        }

        if (file_exists($manifest = public_path('build/manifest.json'))) {
            return md5_file($manifest);
        }

        return null;
    }
madprabh's avatar

@Sinnbeck God I wish my message reached you sooner, it would have saved me hours of research. Thanks a lot for the help!

Please or to participate in this conversation.