Compile assets that depend on node packages using Laravel Envoyer deployment hooks
gulp --production
before deployment is tedious and often forgotten, especialy when you are running gulp watch and assets are being compiled after any change.npm install
on a server during every deployment and compiling it after is slow.Using Envoyer's deployment hooks we can fix the problems so that our assets are compiled when the project is deployed. We can also eliminate how long it takes NPM to download all of the packages we need by storing them in a shared node_modules folder.
Below are the steps required to download your node dependencies and compile your assets during deployment.
After the deployment hook runs for the first time, the deployment time drastically decreases. This is because we need to download all the node packages during the first deployment and then from there we symlink the project's node_modules directory to the release's node_modules directory.
Using one deployment hook containing:
npm install
gulp --production
npm install
npm update
I broke down the steps into 5 different hooks so I could see how long certain steps were taking. The hooks names are listed below.