"/public/build" is listed in gitignore by default??
The production build folder "/public/build" for vite is listed in the .gitignore file by default for new laravel apps.
This directory is where the production asset get generated, in what case would this be ignored???
I was under the impression that the gitignore was done as best practice as we should not be storing build assets inside of the public directory, they can be accessed in the resources directory & vite is only building those assets for development use.
Hmm, not sure that can be best practice, The assets are not accessed directly from the resources directory. The Vite directive that brings in the css & js assets :
simply maps the complied assets to their respective source files in the resource
directory via the public/build/manifest.json file . So, the build directory is required in order to load the assets.
For my own app I use pusher, and I therefor inject env variables into my build process. I also do zero downtime deployment, and build the assets as part of the process
I came here having the same quest while my Forge production failed and I saw the good old Vite Manifest not found error... and I was very confused, if the build process was done automatically in Forge... "by the creators of Laravel!!!" then I would figure they have chosen that builds should be done on the server, but this is not the case, so still a bit confused if there is some wisdom to this, or what?
It is what it is.
@all1.ai Because not every project has a front-end (i.e. API projects). So if you need npm run build running when you deploy, then add it to your deploy script.
@all1.ai
I don't believe that the default deployment script on Forge has a step to automatically build assets.
The point at which your assets are built is determined by you. If you are just pushing the app to Forge , and you are the only one working on the app, then just build your assets locally and push them with everything else, so you would remove the "/public/build" in your gitignore
But, if you are working on a team of people, or you are injecting env vars from the server (there are other cases as well); You would probably build the assets as part of the deployment process; Because other team members may have changed some CSS/JS or the assets are dependent on env vars from the server .