As I said earlier, when the Css,img,js is removed, watch will listen, but it will not delete the corresponding file.
Now implement the clean task and delete the build directory before performing the task.
First configure the JS task, set the delete directory.
On the basis of the series (d) code, expand it.
1. Install Gulp-clean:
NPM Install--save-dev Gulp-clean
2. Locate Gulp->config.js and configure clean:
/*The Gulp command is run by gulpfile.js, so the SRC and build folder paths are as follows (root directory)*/varsrc = './src '; varDest = './build '; Module.exports={less: {all:src+ "/less/**/*.less",//All LessSRC:SRC + "/less/*.less",//Less that needs to be compiledDest:dest + "/css",//Output DirectorySettings: {//compile the configuration required for the less procedure, which can be empty}}, Images: {src:src+ "/img/**/*", Dest:dest+ "/IMG"}, JS: {src:src+ "/js/**/*", Dest:dest+ "/js"}, clean:{src:dest}}
New Clean task in 3.gulp->tasks:
var gulp = require (' Gulp '); var clean = require (' Gulp-clean '); var config = require ('.. /config '). Clean;gulp.task (function() { return gulp.src ( CONFIG.SRC) . Pipe (Clean ());})
4. Also add the clean task to the default task sequence:
Watch out! The following is an error:
Because of this writing, these tasks are synchronous, and it is possible to delete the side compilation edges completely.
Gulp.task (' Default ', [' clean ', ' less ', ' images ', ' js ', ' Watch ']);
So you need to configure an asynchronous, very simple, add a callback:
var gulp = require (' Gulp '); Gulp.task (function() { Gulp.start (' less ', ' Images ', ' js ', ' Watch ') ;
5. Also add clean in the Deploy task sequence:
var gulp = require (' Gulp '); Gulp.task (function() { Gulp.start (' less ', ' Imagemin ', ' uglify ') ;
Running Gulp,build at this time will be deleted first.
Look at the official documents in that sentence too.
>>> GitHub Address, please select the Clean branch <<<
Gulp-clean----Gulp Series (v)