[How to use Gulp under Mac] 2. Common methods of Gulp modules

Source: Internet
Author: User

The common Gulp module methods are:

GULP.SRC ()

GULP.SRC (' client/one.js ');  Specify the explicit file to be processed
GULP.SRC (' client/*.js ');    Processing all files with the suffix. js in the client directory
GULP.SRC (' client/**/*.js '); Working with the client directory and its subdirectories all files that are. js
GULP.SRC ('!client/main.js ');//handling files other than Client/main.js

The Gulp.src () method is used to generate the data stream. The file path to be processed is passed as a parameter to the gulp.src ([' ResourceUrl-1 ',' resourceUrl-1 '), and the specified files are converted to the data stream


Gulp.task ()
Usage One: Specify the specific task
Gulp.task (' Mygulp ', function () {
Console.log (' Hi, Mygulo ')
});

Usage Two: Perform a set of tasks at the same time
Gulp.task (' Bulid ', [' JS ', ' CSS ', ' HTML ')//each task is executed asynchronously

Usage Three: Perform a dependent task
Gulp.task (' detail.css ', [' Base.css '],function () {
Console.log (' Perform a set of tasks in order, execute Base.css and execute detail.css first ')
})

The Gulp.task () method is used to define a specific task, the first parameter is the task name, and the second parameter is the handler function for the task

Gulp.dest ()

GULP.SRC (' Client/one.js ')
. Pipe (Gulp.dest (' bulid/js ')) = > Newly generated file path build/one.js

The Gulp.dest () method is used to write the data stream produced by GULP.SRC () to a file.

GULP.WACTH ()

Gulp.watch (' client/one.js ', [' reBuild ', ' reLoad ']);

Gulp.task (' ReBuild ', function () {
Console.log (' Start rebuild ')
})

Gulp.task (' ReLoad ', function () {
Console.log (' Start reLoad ')
})

The Gulp.wacth () method performs the task based on the state of the listener file change. Once the specified file has changed, the task is performed accordingly.

[How to use Gulp under Mac] 2. Common methods of Gulp modules

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.