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

eddieace's avatar

Envoyer, deploying with npm install and gulp --production

Hi Envoyer fans!

On every deploy I have to run npm install and gulp. This results in longer deploy times.

Is it anyone who have a good solution for this? Cashing the node-modules folder or something like that?

0 likes
4 replies
cmgmyr's avatar

In the past, I set up a "linked" folder in Envoyer for node_modules which sped up the deploy. While this helped some, there were still issues:

  1. It still wasn't that fast.
  2. If you ever had an issue installing new npm packages, and the build failed, you might have to wipe out your shared npm folder.

I've since removed all front end tasks from envoyer and just run and commit everything locally. So my general workflow is:

  1. Work as usual with [gulp|webpack] watch
  2. When ready to commit, stop watcher, run production [gulp|webpack] task
  3. Commit all compiled files - as well as the json manifest files
  4. Push
  5. Auto-deploy with Envoyer

On some projects deploy time went from 4-5 minutes to 20-30 seconds. If you're worried about a bunch of git diff noise with the compiled assets, you can use a .gitattributes file with public/* -diff that will suppress them.

sharelov's avatar
sharelov
Best Answer
Level 14

We do it like this for every deploy...

cd {{release}}
ln -s /home/forge/yourawesomesite.com/node_modules {{release}}/node_modules
ln -s /home/forge/yourawesomesite.com/bower_components {{release}}/bower_components

This will setup symlinks to a node_modules and bower_components folder outside of the release. When we run npm install, the folder is already linked, and all dependencies fall on the linked folder outside the release. On each release we link again with this hook that is run first thing after composer install.

2018-01-29 | Update:

It's been a while, I know... But, as mentioned by cmgmyr, this approach will make it impossible (or really hard, depending on how you specify your package versions in your package.json and bower.json files) to roll-back your front-end dependencies if you do a re-deploy of a previous commit. It will require additional steps performed via hooks as well, or connecting directly to the server via ssh to clear out the linked folders.

I am interested to know how can this be managed locally in a way that it minimizes git conflicts when working with a team. Last time we tried this locally, we had conflicts on each push upstream due to the manifest files (which can't really be ignored on git, right?), compiled js and compiled css which can no longer be ignored by git if we are not running our build scripts on the server... So if anyone has tips on that regard, this thread seems like a good place to share them!

2 likes
cmgmyr's avatar

yup, this is essentially what a "linked" folder in Envoyer does too

Please or to participate in this conversation.