Hi, i am using the latest Laravel Version with Vite for bundling assets. Which deploy strategy with envoyer is the best?
remove public/build from .gitignore and run 'rpm run build' every time on the local machine before push to the repository?
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?
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
@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.
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?
@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...
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