I am writing a nodejs application with Angular as my front end. For this I am having Git as my code management server. For client, I am doing minification and it is ready for production.
But I am not sure, how to prepare server side files for production. Do we need to just copy all the Git folders into production server?. Let me know the best way to deploy nodejs server application.
It really depends on how you (or your company) want to organize the workflow and the size of the project.
Sometimes I too use a GIT repository, because then is really simple to update: just a
git pulland (if server files got edits) apm2 restart Ncommand.In this way, you dont have to install the whole development stack in order to compile (and minify) the bundles - I guess you work on your local machine where all the development tools are installed.
Keep in mind to use the
--devflag while installing packages that are only required in development mode, so you can keep the production server as slim as possible.A good practice I found is to add some random tokens inside the final bundle filename (both for js and css) that get then injected inside the final html static files, to avoid the refresh the page loop.
Once you have the bundle files on your dev machine, just upload them to the server (ftp, git, rsync, sshfs mount, whatever you like) and (if server files got edits) restart/reload the node process (Im using pm2 for this, its really great). If you only edited client files, no reload is needed.
Starting from here, there a lot of ways more or less sophisticated to do the job, like git pipelines for example.. but depends on the situation.
Edit: this is a good article about task runner (gulp vs grunt vs vanilla npm), while may be a little off topic, it analyze some aspect of the common deployment process