//Introduction of GulpvarGulp = require (' Gulp ')); //Introducing ComponentsvarClean = require (' Gulp-clean ');//-ClearvarSass = require (' Gulp-sass ');//-SASS CompilationvarConcat = require (' Gulp-concat ');//-MergervarUglify = require (' gulp-uglify ');//-Compression JSvarMinify = require (' gulp-minify-css ');//-Compress CSSvarRev = require (' Gulp-rev ');//-add MD5 suffix to file namevarRevcollector = require (' Gulp-rev-collector ');//-Path SubstitutionvarCompass = require (' Gulp-compass ');//CompassvarCssspriter = require (' Gulp-css-spriter ');//CSS Sprite ChartvarTinypng = require (' gulp-tinypng ');//tinypng Image Compression//Clear ResourcesGulp.task (' Clean ',function() {GULP.SRC (['./js/*.js '],['./css/*.css '],{read:false}). Pipe (Clean ())})//Compiling sassGulp.task (' sass ', [' Clean '],function() {GULP.SRC ('./sass/*.scss '). Pipe (Sass ()). Pipe (Minify ()). Pipe (Gulp.dest ('./css '));});//CompassGulp.task (' Compass ',function() { varTimestamp = +NewDate (); GULP.SRC ('./sass/*.scss '). Pipe (Compass ({config_file:'./config.rb ', CSS:' CSS ', Sass:' Sass '}). Pipe (Cssspriter ({//the location of the generated SpriterSpritesheet: './dist/images/sprite ' +timestamp+ '. png ', //generate the path to the style file picture reference address //The following will be produced: Backgound:url (.. /images/sprite20324232.png)Pathtospritesheetfromcss: '. /images/sprite ' +timestamp+ '. png '}). Pipe (Gulp.dest ('./css '));});//merging, compressing filesGulp.task (' Concat ',function() {GULP.SRC ('./js/*.js '). Pipe (Concat (' All.js ') . Pipe (Uglify ()). Pipe (Gulp.dest ('./js ')); //. Pipe (Rev.manifest ()); //. Pipe (Gulp.dest ('./rev ')); });//to add a version number to a link, clear the cache//gulp.task (' rev ', function () {//gulp.src (['./rev/*.json ', './application/**/header.php '])//-read Rev-manifest.json files and files that need to be replaced by CSS names//. Pipe (Revcollector ())//-Replace the CSS name in the execution file//. Pipe (Gulp.dest ('./application/')); -the directory where the file output is replaced// });//image CompressionGulp.task (' Tinypng ',function() {GULP.SRC ('./images/* ') //https://tinypng.com/developers Get Api_key //https://tinypng.com/developers/subscription One months free 500 photos. Pipe (Tinypng (' P3A2PUL7IHVFIFPJFJ6KMNHOLS6KBGFW '). Pipe (Gulp.dest ('./dist/images '));});//Default TaskGulp.task (' Default ',function() {Gulp.watch (['./js/*.js ', './sass/*.scss ', [' concat ', ' compass ']);});
Gulp Configuring backups