Front-End Build tool: Configuration and use of gulp

Source: Internet
Author: User

Installing Gulp

Because Gulp is a node-based management tool, install Nodejs first
Installing Nodejs
Nodejs: Chinese Station: http://nodejs.cn/English Station: https://nodejs.org/en/
Run the. msi file directly after download
after the installation is complete, open the command line (win+r) and type node-view node version

Global Installation Gulp

NPM Install-g Gulp

To install Gulp in the project directory, if you want to write gulp into the dependencies of the project Package.json file during installation, you can add –save-dev:
(project directory Installation Gulp Open command line mode: shift+ right mouse button –> choose to open the command line here)

NPM Install Gulp--save-dev

Use Gulp-v to see if the installation was successful (left: Global View Gulp Successful installation, figure right: project directory to see if Gulp installed successfully)

Use gulp
Create the Gulpfile.js file

var gulp = require (' Gulp '); Gulp.task (' default ',function() {    console.log (' (Hello World ');});

Create a Package.json file

NPM Init

Run the Gulp task

Under Projects, open the command line, type Gulp, and perform the task.

project directory structure

gulpapi

GULP.SRC ()

Used to read files

GULP.SRC (globs[, Options])

Gulp.dest ()

Used to write files

Gulp.dest (Path[,options])

Gulp.task ()

Used to define Tasks

Gulp.task (name[, Deps], FN)

Gulp.watch ()

To monitor changes to a file, we can use it to perform tasks, such as file compression, when a file has changed. For example

Gulp.watch (glob[, opts], tasks)

Front-End Build tool: Configuration and use of gulp

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.