Gulp (b) Gulp Chinese API

Source: Internet
Author: User

// match ' client/js/somedir/somefile.js ' and resolve ' base ' to ' client/js/'   . Pipe (Minify ())  . Pipe (Gulp.dest (' build '));  // write ' build/somedir/somefile.js ' gulp.src (' client/js/**/*.js ', {base: ' client ' }).  pipe (Minify ())  . Pipe (Gulp.dest (' Build '));  // write ' build/js/somedir/somefile.js '
Gulp.src ('./client/templates/*.jade ')  . Pipe (Jade ())  . Pipe (Gulp.dest ('./build/templates '))  . Pipe (Minify ())  . Pipe (Gulp.dest ('./build/minified_templates '));
Gulp.task (' Somename ',function() {  //do some things}); Gulp.task (' MyTask ', [' array ', ' of ', ' task ', ' names '],function() {  //do some things});//the task can be executed asynchronously if FN can do one of the following://1. Accept a callback//execute a command in the shellvarexec = require (' child_process '). Exec;gulp.task (' Jekyll ',function(CB) {//compiling JekyllEXEC (' Jekyll build ',function(err) {if(ERR)returnCB (ERR);//return errorCB ();//Complete Task  });});//2. Return a streamGulp.task (' Somename ',function() {  varstream = gulp.src (' client/**/*.js '). Pipe (Minify ()). Pipe (Gulp.dest (' Build ')); returnstream;});//Returns a PromisevarQ = require (' q ')); Gulp.task (' Somename ',function() {  varDeferred =Q.defer (); //performing an asynchronous operationSetTimeout (function() {deferred.resolve (); }, 1); returndeferred.promise;});

var watcher = Gulp.watch (' js/**/*.js ', [' uglify ', ' Reload ']), Watcher.on (function( Event) {  console.log (' File ' + Event.path + ' was ' + Event.type + ', running tasks ... ');}); Gulp.watch (function(event) {  console.log (' File ' + Event.path + ' was ' + Event.type + ', Runni ng tasks ... ') ;

Reference:

http://www.ydcss.com/archives/424

https://www.gulpjs.com.cn/docs/api/

Gulp (b) Gulp Chinese API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.