learn gulp from scratch

Installation method: npm install gulp --save-dev Install to the current project directory After the
installation is complete, we can learn from several important apis of gulp.
1, task: method is used to define task

2, src: read file stream, what gulp reads is not the original file stream, but a virtual file object stream.

3,dest: write to the file stream The
writing rules are as follows:
//If there is no wildcard,
gulp.src('script/avalon/avalon.js') 
.pipe(gulp.dest('dist')); //finally The generated file path is dist/avalon.js
//The part of the path where wildcards begin to appear is **/underscore.js
gulp.src('script/**/underscore.js') //Assume the matching file is script/util/underscore.js
.pipe(gulp.dest('dist')); //The final generated file path is dist/util/underscore.js gulp.src('script/*')
//There are wildcards The part of the path that appears is *
//Assume the matching file is script/zepto.js
.pipe(gulp.dest('dist')); //Then the final generated file path is dist/zepto.js
By specifying the `base` property in the `gulp.src()` method configuration parameter, we can more flexibly change the file path generated by `gulp.dest()`. When we do not configure the `base` property in the gulp.src()` method, the default value of `base` is the part of the path before the wildcard starts, for example: gulp.src('app/src/**/*. css') At this time, the value of base is app/src.

4, watch: used to monitor the changes of the file, when the file changes, we can use it to perform the corresponding tasks

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945798&siteId=291194637