html5中文学习网

您的位置: 首页 > 网站及特效实例 > html5实验 » 正文

Grunt 使用说明

[ ] 已经帮助:人解决问题

Gruntjs是一款基于nodejs的javascript项目的自动化构建工具。很多知名的开源项目都在使用,如:jquery、yui、qunit、angular.js、CanJS、Modernizr等。BrLHTML5中文学习网 - HTML5先行者学习网

一、安装nodejs

nodejs.org/#downloadBrLHTML5中文学习网 - HTML5先行者学习网

如果以前全局安装过grunt 0.3x,执行以下命令

npm uninstall -g grunt

二、安装grunt-cli

npm install -g grunt-cli

三、安装templates

//clone the template inside of the ~/.grunt-init/ directory.//http://gruntjs.com/project-scaffolding#installing-templatesgit clone https://github.com/gruntjs/grunt-init-jquery.git ~/.grunt-init/jquerygit clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile

四、已经存在的grunt项目

安装插件

如果有配置文件package.json,执行npm install可以安装项目依赖的Grunt插件BrLHTML5中文学习网 - HTML5先行者学习网

npm install

或者直接通过官网gruntjs.com/plugins安装插件BrLHTML5中文学习网 - HTML5先行者学习网

使用

grunt//执行默认命令

五、新建grunt项目

创建项目

mkdir projectgrunt-init template //如grunt-init gruntfile

当前项目下安装grunt

npm install grunt --save-dev

package.json

可以在这个文件中配置项目依赖的Grunt插件BrLHTML5中文学习网 - HTML5先行者学习网

配置Gruntfile

文件名为Gruntfile.js或Gruntfile.coffee,在这个文件中配置各种构建任务及其加载任务所需要的插件。BrLHTML5中文学习网 - HTML5先行者学习网

安装插件

如果有配置文件package.json,执行npm install可以安装项目依赖的Grunt插件BrLHTML5中文学习网 - HTML5先行者学习网

npm install

或者直接通过官网gruntjs.com/plugins安装插件BrLHTML5中文学习网 - HTML5先行者学习网

使用

grunt//执行默认命令,也可以使用

六、前端开发推荐插件

grunt-contrib-cleanBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-clean --save-dev

grunt-contrib-concatBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-concat --save-dev

grunt-yui-compressorBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-yui-compressor

grunt-contrib-csslintBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-csslint --save-dev

grunt-contrib-jshintBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-jshint --save-dev

grunt-contrib-qunitBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-qunit --save-dev

grunt-contrib-copyBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-copy --save-dev

grunt-contrib-uglifyBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-uglify --save-dev

grunt-imagine npm install grunt-imagineBrLHTML5中文学习网 - HTML5先行者学习网

grunt-contrib-imageminBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-contrib-imagemin --save-dev

grunt-asset-revisionsBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-asset-revisions

grunt-assets-revvingBrLHTML5中文学习网 - HTML5先行者学习网

npm install grunt-assets-revving
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助