- Gulp - Cleaning Unwanted Files
- Gulp - Useful Plugins
- Gulp - Optimizing Images
- Gulp - Optimizing CSS and JavaScript
- Gulp - Live Reload
- Gulp - Watch
- Gulp - Combining Tasks
- Gulp - Developing An Application
- Gulp - Basics
- Gulp - Installation
- Gulp - Overview
- Gulp - Home
Gulp Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Gulp - Cleaning Unwanted Files
In this chapter, you will learn how to clean generated files. As we are automatically generating the files, make sure that unnecessary files should be deleted before running your build. This procedure is called cleaning. The del plugin can be used for this purpose.
Instalpng del Plugins
In your command pne install the plugin by entering the following command.
npm install del --save-dev
Declare Dependencies and Create Tasks
In your configuration file gulpfile.js, declare the dependencies as shown in the following command.
var del = require( del );
Next, create a task as shown in the following code.
gulp.task( clean:build , function() { return del.sync( build ); });
The above task will clean entire build. The clean task clears any image catches and removes any old files present in build.
It is possible to clean only specific file or folder and leave some of them untouched as illustrated in the following code.
gulp.task( clean:build , function() { //return del.sync( build ); return del([ build/temp/ , // instructs to clean temp folder !build/package.json // negate to instruct not to clean package.json file ]); });
In the above task, only the temp folder will be cleaned leaving package.json untouched.
Advertisements