1. Installing Gulp
CNPM Install-g Gulp;
2. Then also need to install Gulp in the current directory, specifically, only know that after the installation will be in the current directory under the Node_modules more than one Gulp folder
CNPM Install Gulp--save-dev
There's a great God who knows, and he's looking for guidance.
3. Create Package.json, you can cnpm init or write yourself manually, the content is as follows
{"Name": "Gulptest", "Version": "1.0.0", "description": "description", "Main": "Gulpfile.js", "dependencies": {"Gulp": " ^3.9.0 "," Gulp-rename ":" ^1.2.2 "," Gulp-jshint ":" ^1.11.2 "," Gulp-concat ":" ^2.6.0 "," gulp-uglify ":" ^1.4.0 "," Gulp-util ":" ^1.0.0 "}," Devdependencies ": {" Gulp ":" ^3.9.0 "}," scripts ": {" test ":" Test Command "}," repository ": {" type " : "Git", "url": "Git Repository"}, "keywords": ["keywords"], "author": "Author", "License": "ISC"}
4. Installation-related dependencies
CNPM Install
5. Create gulpfile.js with the following content
var Gulp = require (' gulp '); var gutil = require (' Gulp-util '); var uglify = require (' gulp-uglify '); var Concat = require (' Gulp-concat '); Gulp.task (' Concat ', function () { gulp.src ('./src/*.js ') . Pipe (Uglify ( ) . Pipe (concat (' all.min.js ')) . Pipe (Gulp.dest ('./build '));}); Gulp.task (' Default ', [' concat ']);
6. Execute gulp and you will see the following results
Demo of Gulp