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