A few basic steps to keep in mind when getting started with gulp

Source: Internet
Author: User

Come on, write a few basic introductory steps to use the Gulp tool to make your memory easier to understand. (As for, if you do not know what gulp is, you can look at my Gulp introductory collection)

The steps here are not particularly detailed. Here is just a note of some introductory steps or preparations before using the Gulp tool.

1 First of course we need to install the Nodejs, Baidu search Nodejs into the official website download can;

2 after the installation is complete, you can enter at the command line: Npm-v to view the version number of NPM (determine if the Nodejs is properly installed);

3 Install CNPM, execute on the command line ($ has another meaning in Linux, no need for us to enter $ in Windows and Linux)

$ NPM install-g cnpm--registry=https://registry.npm.taobao.org
You can use Cnpm-v to view its version number to determine if it is properly installed. We will use CNPM instead of NPM command in the following operation. (as far as the meaning of this step is described above);

4 Global Install Gulp, execute on command line

$ cnpm Install Gulp-g
The global installation of Gulp installs content into C:\USERS\DREAMBOY\APPDATA\ROAMING\NPM (for example, Dreamboy users in Windows systems). The purpose of the global Install Gulp is to execute the Gulp command;

5 Now we need to create a project or project, such as: Gulptest.

Enter the directory of the project at the command line, and then execute the following command:

$ CNPM Init
Using this command to automatically create a Package.json configuration file (which is an essential configuration file for a basic Nodejs project) is stored in the root directory of the project. After executing the command, we are prompted to enter the following necessary parameters: Name (project name), version (Project edition), description (project description);

6 We need to install the Gulp plugin locally, use the following command in the current project directory:

$ cnpm Install--save-dev Gulp
Install the Gulp plug-in locally with this command, and the Package.json configuration file will update the dependency description of the plug-in to the file after the installation succeeds. (If you delete the plug-in Node_modules directory that is dependent on the project, you can use the command CNPM install under the project directory, which downloads the plug-in to the Node_modules directory based on the dependency instructions in the Package.json configuration file.) Don't believe you try it)

PS: Global Install Gulp is to perform gulp tasks, local installation Gulp is to invoke the function of Gulp plug-in.

7 in order to use the Gulp plug-in, we also need to create a gulpfile.js file in the project, which can be in the root directory of the project, which is the Gulp project configuration file. Basic formats such as:

var gulp = require (' gulp ');

Gulp.task (' Default ', function () {
    //Place your default task code here
});

Run Gulp on the command line
the
default task, named Default, will be run, where the task is not doing anything.
to perform specific tasks (task) individually, enter Gulp <task> <othertask>.
 */

8 can execute command Gulp in the current project directory. The tasks defined in the Gulpfile.js file are executed. In order to automate our project development process, we need to be flexible in using more gulp plug-ins to define the tasks in the pipeline in the Gulpfile.js file. The process of installing Gulp other plug-ins is consistent with the local installation gulp. There will be different uses for different plug-ins.


summed up here so far. Come on!


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.