var gulp = require (' Gulp '), Cssmin = require (' gulp-clean-css '),//compress css file Concat = require (' Gulp-concat '),/ /merge js file Jsmin = require (' gulp-uglify '),//compress js file Imgmin = require (' gulp-imagemin '),//Picture Compression rename = R Equire (' Gulp-rename '),//File Rename Jshint = require (' Gulp-jshint '),//js file Check rev = require (' Gulp-rev '),//-to file name Add MD5 suffix revcollector = require (' Gulp-rev-collector '),//path Replace connect = require (' Gulp-connect '); Configure the local server//######## #文件监听及自动刷新网页start ################ #gulp. Task (' Connect ', function () {Connect.server ({host: ') localhost ',//address, can not write, do not write, default localhost port:3000,//port number, can not write, default 8000 root: './',//Current project home directory Livereload: True//Auto-refresh}); Gulp.task (' HTML ', function () {gulp.src ('./bill/*.html '). Pipe (Connect.reload ());}); Gulp.task (' Watch ', function () {Gulp.watch ('./bill/css/*.css ', [' html ']);//monitor CSS file Gulp.watch ('./bill/js/*.js ', [' HTML ']); Monitor JS file Gulp.watch (['./bilL/*.html '], [' HTML ']); Monitor HTML file}), Gulp.task (' Server ', [' Connect ', ' Watch ']),//######## #文件监听及自动刷新网页end ################ #gulp. Task (' Cssmin ', function () {GULP.SRC ("bill/css/common.css"). Pipe (rename ({suffix: '. Min '}). Pipe (CSSM In ({dubug:true}, function (Details) {console.log (details); Console.log (Details.name + ' (originalsize): ' + details.stats.originalSize); Console.log (Details.name + ' (minifiedsize): ' + details.stats.minifiedSize); }). Pipe (rev ()). Pipe (Gulp.dest ("Bill/css")). Pipe (Rev.manifest ())//-generates a rev-manifest. JSON. PIPE (Gulp.dest (' bill/css ');}); Gulp.task (' Jsmin ', function () {GULP.SRC ("bill/js/common.js"). Pipe (rename ({suffix: '. Min '}). P Ipe (Jsmin ()). Pipe (rev ()). Pipe (Gulp.dest ("Bill/js")). Pipe (Rev.manifest ())//-generate a Rev-m Anifest.json. Pipe (Gulp.dest (' Bill/js ');}); gulp.tAsk (' Imgmin ', function () {GULP.SRC ("src/img/*.jpg"). Pipe (Imgmin ({optimizationlevel:5,// Type: Number default: 3 Value range: 0-7 (Optimization level) progressive:true,//Type: Boolean default: False lossless compression jpg picture interlace D:true,//Type: Boolean default: False interlaced GIF for rendering multipass:true//Type: Boolean default: False optimize SVG multiple times until full optimization} ). Pipe (Gulp.dest ("dist/img");}); Gulp.task (' rev ', function () {GULP.SRC (['./bill/**/*.json ', "./bill/index.html"])//-read the Rev-manifest.json file and need to replace the file. Pipe (Revcollector ({replacereved:true, D Irreplacements: {' css ': ' CSS ', ' js ': ' JS '} })//-executes the name of the file. Pipe (Gulp.dest ('./bill ')); -Replace the file output directory});//Perform configuration Tasks Gulp.task (' Default ', [' cssmin ', ' jsmin ', ' rev '], function () {//Gulp.start (' Testjsmin ');}) ;
My gulp.js list.