gulpgulp-4

Why do I need Gulp 4 exports + what do I push to Github repo using Gulp 4


everyone. I have been learning Gulp 4 so far and I have two questions about it:

  1. When I was reading articles about Gulp 4, I saw that functions are exported (usually at the bottom of gulpfile.js file). For instance, exports.style = style. I would like to know what is it for and whether it is obligatory or maybe it should be done in particular cases...

  2. When I push my project to Github repo, I export only files in so-called "build" folder (where all optimized files are located) + index.html itself, don't I? Just need clarification.

Thank you for your replies!


Solution

    1. These functions will become runnable gulp tasks. In your example, you can call this function from command line using gulp style. However it is better to organise functions into tasks instead of exporting every single one unless you really want to execute them separately.
    2. Depends, if push the code to share with other developers, you usually push original source files, gulpfile.js, package.json and package-lock.json / yarn.lock and skip optimized files. If you are pushing it for deployment only, you obviously do not need source files or gulp-related files and can push optimized files only (although in this case, it is probably better to push everything and configure deployment to skip unnecessary files).