JaroslavStefanec's avatar

Vite manifest not found during production build (Zero downtime deployment)

Hello,

I’d like to ask if anyone has found a way to prevent laravel application crashes during the production build process.

For instance, when I change or add a CSS class, I need to run npm run build on the server. However, during the final step of creating the manifest file, the entire application becomes inaccessible, displaying the error: Vite manifest not found at: location/public/build/manifest.json.

Is there a way to avoid this situation? Using php artisan down just to rebuild a single CSS class doesn’t seem like a practical solution.

Thank you in advance!

0 likes
6 replies
ianflanagan1's avatar

You can deploy a whole new build in a different directory, set it all up while the old build is active, then switch over once the build is complete. The easiest way to do it is using symlinks:

/project
	/current   (symlink pointing to /project/releases/build1)
	/releases
		/build1
		/build2
ln -s /project/releases/build2 /project/current

If the webserver reads from /project/current, it doesn't know there's any change

If there is a disastrous bug in the new build, you can rollback to the old build by changing the symlink back again.

To ask (or google) your question better, you should be using words like "downtime", e.g. this is a "zero downtime deployment strategy". Naming your question as "Vite manifest not found during production build" is completely misleading.

JaroslavStefanec's avatar

Thanks for your reply. I understand the symlink approach, but what I can't figure out is why this process seems to require additional steps in Vite, whereas it works almost automatically in Webpack. Perhaps I missed something in the documentation.

Also, thank you for suggesting a title change. I will update it. However, I chose the title because it reflects the exception the application throws during the npm run build, specifically during the transforming stage

ianflanagan1's avatar

@JaroslavStefanec

the entire application becomes inaccessible

To clarify, are you asking why the Laravel application has errors while npm run build is running? It's like trying to drive a car while the mechanic's tools are in the engine. When crucial files are missing, any request that runs at that moment will have errors. That's why Laravel as maintenance mode.

JussiMannisto's avatar

@ianflanagan1 npm run build only modifies the build directory as the last step. So while there's a tiny window while the old build directory is being deleted and the cached files written out, the assets are not broken during building.

1 like

Please or to participate in this conversation.