Home  >  Article  >  Web Front-end  >  Automatic task runner based on Nodejs--Introduction to gulp

Automatic task runner based on Nodejs--Introduction to gulp

零下一度
零下一度Original
2017-06-23 09:51:461694browse

Introduction

gulp是基于Nodejs的自动任务运行器, 她能自动化地完成 javascript/coffee/sass/less/html/image/css 等文件的的测试、检查、合并、压缩、格式化、浏览器自动刷新、部署文件生成,并监听文件在改动后重复指定的这些步骤。
在实现上,她借鉴了Unix操作系统的管道(pipe)思想,前一级的输出,直接变成后一级的输入。主要呢,就是用来帮助我们更快构建。

Common address

gulp官方网址:http://gulpjs.comgulp插件地址:http://gulpjs.com/pluginsgulp官方API:https://github.com/gulpjs/gulp/blob/master/docs/API.mdgulp中文API:http://www.ydcss.com/archives/424

Install node, check version command :

node -v 查看安装的nodejs版本,出现版本号,说明刚刚已正确安装nodejs。PS:未能出现版本号,请尝试注销电脑重试;
npm -v 查看npm的版本号,npm是在安装nodejs时一同安装的nodejs包管理器,那它有什么用呢?稍后解释;
cd 定位到目录,用法:cd + 路径 ;
dir 列出文件列表;
cls 清空命令提示符窗口内容。

Because the npm server is abroad, if there is no FQ and npm is particularly slow, you can consider installing the Taobao image file and install the cnpm command

npm install cnpm -g --registry=https:

npm installation parameter description:

-g:全局安装--save:将保存配置信息至package.json(package.json是nodejs项目配置文件);-dev:保存至package.json的devDependencies节点,不指定-dev将保存至dependencies节点;一般保存在dependencies的像这些express/ejs/body-parser等等。

npm installation, uninstallation, update, help, list Install plug-in command:

使用npm卸载插件:npm uninstall <name> [-g] [--save-删除全部插件:npm uninstall gulp-less gulp-uglify gulp-concat ……???借助rimraf:npm install rimraf -使用npm更新插件:npm update <name> [-g] [--save-更新全部插件:npm update [--save-

npm automatically generates the configuration file

npm init  //运行后会让你填些项目名 版本号等信息,也可以开始不填写,一路回车。
//完成后会在你的项目里生成一个package.json的配置文件。
//之后你用npm install <name> --save 就会自动保存到这个文件。

Install Npm After that, install gulp globally

npm install gulp -g

Then create a new gulpfile.js file in your project and start writing the automated pipe. You can refer to the following and finish writing. After the task that needs to be automated, type the named line directly

gulp <pipeName>

The above is the detailed content of Automatic task runner based on Nodejs--Introduction to gulp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn