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

DominikEller's avatar

Envoyer Deployment with Vite

Hi, i am using the latest Laravel Version with Vite for bundling assets. Which deploy strategy with envoyer is the best?

  1. remove public/build from .gitignore and run 'rpm run build' every time on the local machine before push to the repository?

  2. add a custom deployment hook to envoyer to install npm dependencies and run 'npm run build' on the production server?

Disadvantage of version 1: You often forget to run the npm build command on the local machine before pushing code to repository and I think there should be a reason why public/build is excluded from git by default.

Disadvantage of version 2: There is no zero downtime deployment, because vite manifest is missing until build is done.

So how do you deploy your code with the latest Laravel version and Vite as asset bundler?

0 likes
10 replies
Nihir's avatar

I go with Version 2 as per you mentioned that the vite manifest is missing until the build is done can wait to build, and I don't think it will take a lot of time to generate a build

DominikEller's avatar

@Nihir yes, but it is not zero downtime anymore. So there should be a solution for that I guess. Could be one to allow custom deployment hooks to run before new deployment gets activated.

aleahy's avatar

Correct me if I'm wrong, but doesn't Envoyer do the deployment to a different folder, completely separate from the current deployment. And then only after the build has completely finished does it symlink the current folder to the new deployment?

So why would a missing vite manifest make a difference, since the existing manifest would not be touched?

DominikEller's avatar

@aleahy You are right, but you cannot put your deployment hook between the default ones. So the new deployment is activated before the npm part could run. The vite build takes up to 30 seconds...

DominikEller's avatar

@aleahy that's it. Seems to be new - at least for me. I thought it was not possible - thanks so much!

denizaygun's avatar

@DominikEller this was the solution for me also. Although I didn't have to install dev dependencies like you mentioned in your other reply.

I just had to add it after composer dependencies are installed and before the new release is activated

cd {{ release }}

npm install
npm run build
1 like
joelcraenhals's avatar

Hey guys,

Can you explain what you exactly configured? Vite is not found in my Laravel Envoyer setup when I try to run npm run dev or build commands.

DominikEller's avatar

@joelcraenhals you have to install your dev dependencies on that Server with a deployment hook as well.

npm install --save-dev

It works just fine, but it is for sure not best practice.

I am going to ask the developer team on Github maybe

vpuentem's avatar

Hey, i'm curious on what you ended up doing cause i'm having a similar issue.

I currently have multiple web servers and I run the build process on each, this has an issue that if something is different on the servers (node version, etc.) the build hash from Vite might not be the same which causes errors. So I created a command to publish the assets to S3, so i build them on only one server and then publish them to S3, so other servers consume them using ASSET_URL, this works but I dont like building the assets on the production server so now I'm trying the build the assets on a github action and upload them to S3, but not sure what is the best approach

Please or to participate in this conversation.