http://computertriksno1.blogspot.in/

Gulp: Cleaning up generated files automatically

16 Apr 2017 0 comments


Since we're generating files automatically, we'll want to make sure that files that are no longer used don't remain anywhere without us knowing.

This process is called cleaning (or in simpler terms, deleting files).

We'll have to use del to help us with cleaning.

npm install del --save-dev


var del = require('del');

The del function takes in an array of node globs which tells it what folders to delete.

Setting it up with a Gulp task is almost like the first "hello" example we had.


gulp.task('clean:dist', function() {
  return del.sync('dist');
});

Now Gulp will delete the `dist` folder for you whenever gulp clean:dist is run.

Note: We don't have to worry about deleting the dist/images folder because gulp-cache has already stored the caches of the images on your local system.

To clear the caches off your local system, you can create a separate task that's named `cache:clear`


gulp.task('cache:clear', function (callback) {
return cache.clearAll(callback)
});

Phew, that's a mouthful. Let's combine all our tasks together now!
Click here for For next Step:  "Combining Gulp tasks"

Table of Contents:  "Table of Contents to learn"
Share this article :

Post a Comment

 
Support : GDDon | Creating Website | Gddon |
Copyright © 2013. Computer Tricks and Tips for System - All Rights Reserved
Template Created by Creating Website Modify by GDDon.Com
Proudly powered by Blogger