2 years ago

How to automatically make sure I have --production assets on deployment?

Posted 2 years ago by unitedworx

How do you guys/gals make sure you have production assets on deployment?

At the moment I use Envoyer to deploy and I need to remember to manually run "gulp --production" before pushing to my remote repo. This is flawed since some times I might forget to do so and my assets wont be 300KB they will be 5-6MB :) which is a problem!

I think I have 2 options to handle this.

  1. A pre-push hook to run "gulp --production" and commit anything inside the build directory and then proceed to push to my remote. I have no idea how to code this thought! Anyone doing this to share your pre-push hook script?

  2. bite the bullet and install node/gulp/yarn on my server and make sure that part of my Envoyer deployment scripts run "yarn install" and then "gulp --production" on deployment. I was highly against this since node_modules is fairly big around 200MB and npm install is very slow! Envoyer keeps 5-6 previous revisions so its actually 200MB*5=1GB of wasted space on my server, per project! I guess I can delete node_modules after running "gulp --production" as part of my deployment script to keep things clean and now that I am using yarn and its caching stuff It runs considerably faster so I suppose it wont take long. Anyone following this approach? Any advise? for or against this approach?

Please sign in or create an account to participate in this conversation.