javascript前端工具------自动化构建工具Grunt
2016-05-15 11:55
639 查看
Grunt官网网址:http://gruntjs.com/
首先要明白grunt的作用是什么:它能帮我们做一些简单的、重复性的、程序员一般都不愿自己去做的工作,比如说单元测试、代码的压缩和代码的校验等等。它能更好的帮助我们管理项目。
1.安装Grunt
首先必须安装了nodejs,然后使用npm命令安装:
cli的意思是command line interface(命令行接口)
2.项目中运用Grunt
(1)项目中需要在package.json配置Grunt;有3种方式创建package.json
- 可以在终端使用命令创建package.json,不过要先安装grunt-init;
- 通过npm inti
- 通过手写文件
在这里,我通过第二种方式创建package.json.
创建之后是没有把相关的依赖加进去的,想要加进去,可以通过以下方式:
(2)要有Gruntfile.js或者Gruntfile.coffee
未完待续。。。
首先要明白grunt的作用是什么:它能帮我们做一些简单的、重复性的、程序员一般都不愿自己去做的工作,比如说单元测试、代码的压缩和代码的校验等等。它能更好的帮助我们管理项目。
1.安装Grunt
首先必须安装了nodejs,然后使用npm命令安装:
npm install grunt-cli -g
cli的意思是command line interface(命令行接口)
2.项目中运用Grunt
(1)项目中需要在package.json配置Grunt;有3种方式创建package.json
- 可以在终端使用命令创建package.json,不过要先安装grunt-init;
- 通过npm inti
- 通过手写文件
在这里,我通过第二种方式创建package.json.
E:\f>npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (f) test version: (1.0.0) 0.1.0 description: My test project entry point: (index.js) index.html test command: git repository: keywords: author: license: (ISC) About to write to E:\f\package.json: { "name": "test", "version": "0.1.0", "description": "My test project", "main": "index.html", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" } Is this ok? (yes) yes
创建之后是没有把相关的依赖加进去的,想要加进去,可以通过以下方式:
npm install grunt --save-dev
(2)要有Gruntfile.js或者Gruntfile.coffee
未完待续。。。
相关文章推荐
- 使用基于Node.js的构建工具Grunt来发布ASP.NET MVC项目
- Node.js的项目构建工具Grunt的安装与配置教程
- 配置Grunt的Task时通配符支持和动态生成文件名问题
- 学习使用grunt来打包JavaScript和CSS程序的教程
- 详解Grunt插件之LiveReload实现页面自动刷新(两种方案)
- 用grunt构建seajs项目遇到的各种坑
- Grunt 新手指南
- Node.js的项目构建工具Grunt的安装与配置教程
- grunt的使用
- Grunt学习笔记(从零配置grunt)
- Node.js+Yeoman构建前端自动化Web应用
- 一步步学会使用SeaJS 2.0
- grunt.config.init()_gruntjs api
- grunt.config()_gruntjs api
- grunt.config.get()_gruntjs api
- Grunt——前端任务自动管理工具
- grunt让Nodejs规范起来
- Grunt配置全过程
- grunt.config.init()_gruntjs api
- grunt.config()_gruntjs api