3. Gulp Installation and use

Source: Internet
Author: User

Environment

Installing Gulp and Grunt is all about node's package management tool-NPM, so you'll need to install node on your computer so you can install Gulp and Grunt. (Install node automatically installs NPM, detects installation success Node-v, NPM-V)

Installation

To use Gulp in your project, you need to install the GULP command-line tool in the global scope first, then install the Gulp in the project. (If you encounter permission problems, add sudo before the command)

Install -G gulp

Go into the project and install the Gulp.

Install Gulp

Then enter NPM init to create a Package.json file for the project, so that the gulp as a project development dependency, put into this Package.json file

NPM Init

Use of Gulp

Module Installation (--save-dev means to rely on the module as the development of the project, put it in the Package.json file. )

Install module name  --save-dev

Task Creation

    varGulp = require (' gulp ');//let the gulp variable have all the Gulp methods, create gulp tasks, and use the Gulp task method    varUglify = require (' gulp-uglify ');//Compression JS    varRename = require (' Gulp-rename ');//renaming    //Create a taskGulp.task (' A ',function() {        returnGULP.SRC (' Src/main.js '). Pipe (Uglify ())// Piping Pipe. Pipe (Gulp.dest (' dest '));    }); //Create a B taskGulp.task ("B",function(){        returnGULP.SRC ("Src/main.js"). Pipe (Rename ("A.min.js"). Pipe (Gulp.dest ("Dest"));//Direct Write output directory               //. Pipe (Gulp.dest ("dest/a.min.js")); Error    }); Gulp.task (' Default ', [' A ', ' B ']);

task Execution (need to go to the directory where the project is executed)

The greet here is the task name, a is a task, B is the B task, and default is all tasks in []

Gulp A

3. Gulp Installation and use

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.