First, install the Gulp
1. Before setting up the task in depth, you need to install Gulp:
$ NPM Install Gulp-g
2. This will install gulp into the global environment, allowing you to access the Gulp CLI. Next, you need to install the project on the local side. CD to your project root directory and execute the following instructions (please make sure you have the Package.json file):
$ npm Install Gulp--save-dev
Ii. Generating file structure
(Generate Node_modules file)
Iii. Creating a Gulpfile.js file
var gulp = require (' Gulp '),
Uglify = require ("gulp-uglify"); //uglify for JS compression
Gulp.task (' Default ', [' JS '], function () {
Console.log (' js file is beginning ... ');
});
Gulp.task (' JS ', function () {
Console.log (' >>>start task:js ');
GULP.SRC (' scripts/app/reacttest/reacttest.js ') //directory files that need to be packaged
. Pipe (Uglify ()) //uglify for JS compression
. Pipe (Gulp.dest (' Compressfile/js ')); //package to target location
});
Four, then execute
Execute gulp default on CMD or CD to project directory to execute command Gulp--gulpfile gulpfile.js
Download the file code on git
Gulp JS Simple operation-to be continued