Hi all,
I am just wondering what’s the general advice for deployment. I am not using Bedrock / Trellis so this would be standard WordPress structure.
I am pushing my files from Local to GitHub. After that, Staging will pull the files from Github. What I noticed is that the public folder is not pushed to GitHub and it’s part of gitignore within the theme so I am getting an error that the asset manifest cannot be found.
Am I supposed to run yarn build
on the staging environment in this case? I read somewhere that composer install
should be used but unsure where as well. Otherwise, can I uncomment public
so it pushes to GitHub too?
1 Like
The best practice is to build your “artifacts” (the result of your compiled CSS, JS, etc) either on the machine that will be running the site (your staging
environment) or on a machine identical to it.
After your staging machine pulls your theme files from GitHub, you need to perform the following steps in the theme’s directory on your staging
machine:
- run
npm install
- run
composer install
- run
npm run build
(The trellis build-before script is a good reference for the steps you need to perform during deployment to get a functioning theme)
There are a dozen ways you could perform these steps, from manually on your local machine and FTP, to a GitHub action that deploys automatically on push
.
This is where Trellis really helps development in general, because its whole deal is making identical environments for development
, staging
, and production
.
Thanks for the info! Now I have a better idea in this case.
With that said, if I am running the commands in staging or prod, does it mean that files like package.json
and composer.json
are publicly accessible via the URL?