How to deploy gulp on a production server

When creating a website (for clarity, only an HTML / JS website) I use gulp to compile and concatenate some files, which are then placed in the build/ folder.

The folder structure looks something like this:

 β”œβ”€β”€ assets β”‚  β”œβ”€β”€ images β”‚  β”œβ”€β”€ javascripts β”‚  β”‚  └── app.js β”‚  └── stylesheets β”‚  └── style.scss β”œβ”€β”€ bower.json β”œβ”€β”€ build β”‚  β”œβ”€β”€ bower_components β”‚  β”œβ”€β”€ images β”‚  β”œβ”€β”€ index.html β”‚  β”œβ”€β”€ scripts.min.js β”‚  └── styles.min.css β”œβ”€β”€ gulpfile.js β”œβ”€β”€ index.html β”œβ”€β”€ node_modules β”‚  β”œβ”€β”€ gulp-module-1 β”‚  └── gulp-module-2 β”œβ”€β”€ package.json └── README 

If I include all these files in the git repository, all my changes will be committed twice. That is: a change in assets/stylesheets/style.scss will also lead to a change in build/styles.min.css . However, if I decided to exclude the build/ folder from the repository, you will need certain development tools on the production server (for example, gulp, npm, etc.). Sometimes this can be difficult when there are limited privileges on the production server. Obviously, excluding the assets/ folder is not an option, since you will lose the source for the compiled files.

So my question is: what is considered best practice for deployment to a production server? Do you include the build/ folder in the repo, are you compiling the build/ folder on the production server, or is there a third solution?

+8
git gulp
source share
1 answer

Although not everyone can agree on what is the best solution for this problem, I think there is a third solution that you missed, and which I usually prefer. You can collect all the files on your development machine, and then deploy the files that were created on your production server. Usually this will be just a copy action.

Thus, you will not need any development tools on your server, and you will not have builds in your version control system.

+7
source share

All Articles