1,http://nodejs.org/download/ 安装nodejs

2,配置环境变量,将nodejs的安装目录放置在Path环境变量中

3,在cmd中 npm install -g grunt-cli,如果已经安装的话npm uninstall -g grunt  这句话可以删除

4,grunt -version 可以查看是否安装成功

5,在要压缩的跟目录中创建package.json

6, 一个简单的package.json样例

{
"name": "umeditor",
"title": "umeditor",
"description": "umeditor",
"version": "1.2.2",
"homepage": "https://github.com/fex-team/umeditor",
"author": {
"name": "f-cube @ FEX",
"url": "http://fex.baidu.com"
},
"repository": {
"type": "git",
"url": "https://github.com/fex-team/umeditor.git"
},
"keywords": [
"umeditor",
"web editor",
"ueditor",
"javascript"
],
"bugs": {
"url": "https://github.com/fex-team/umeditor/issues"
},
"dependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-closurecompiler": "~0.9.9",
"grunt-contrib-copy": "~0.4.0",
"grunt-transcoding": "~0.1.1",
"grunt-text-replace": "~0.3.9",
"grunt-contrib-compress": "~0.7.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "^0.3.0",  
"grunt-contrib-uglify": "^0.5.1"
}
}

7,创建 Gruntfile.js

一个简单的样例

module.exports = function(grunt) {

grunt.initConfig({

//our JSHint options

//our concat options
concat: {
options: {

},
dist: {
src: ['Src/*.js'], //Grunt mini match for your scripts to concatenate
dest: 'dest/edit.js' //where to output the script
}
},

//our uglify options
uglify: {
js: {
files: {
'dest/edit.js': ['dest/edit.js'] //save over the newly created script
}
}
}

});

//load our tasks
//grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');

// default tasks to run
grunt.registerTask('default', ['concat', 'uglify']);
//grunt.registerTask('development', ['jshint']);
//grunt.registerTask('production', ['jshint', 'concat', 'uglify']);
}

7,执行npm install grunt --save-dev  可以将最新的grunt到你的目录下

8,执行grunt 命令就实现打包了

最新文章

  1. ceph hadoop spark 大数据处理
  2. C#设计模式-原型模式
  3. Autorelease返回值的快速释放机制
  4. 自定义UICollectionLayout布局 —— UIKit之学习UICollectionView记录一《瀑布流》
  5. 用Android模拟器也可以开发和测试NFC应用
  6. JSP实现数据传递与保存
  7. LEARUN 开发框架 /aspnetboilerplate ----上海力软信息技术有限公司
  8. linux系统man查询命令等级与意义
  9. syntax error near unexpected token `then'
  10. HTML5终极备忘大全
  11. C++结构简介
  12. android 中动画
  13. django url调度
  14. c#抽取pdf文档标题(2)
  15. 使用脚本删除hive分区中的问题(expecting KW_EXCHANGE near mytable in alter exchange partition)
  16. hdu 5446(中国剩余+lucas+按位乘)
  17. 【爆料】-《伯明翰大学学院毕业证书》UCB一模一样原件
  18. 三、vue之router
  19. [Swift]LeetCode8. 字符串转整数 (atoi) | String to Integer (atoi)
  20. 湘潭邀请赛+蓝桥国赛总结暨ACM退役总结

热门文章

  1. BZOJ1003物流運輸 DP + SPFA
  2. 【转载】GitHub中国区前100名到底是什么样的人
  3. C# 使用xenocode混淆加密【转】
  4. [Algorithm] Linked List Data Structure in JavaScript
  5. Optimizer统计信息管理介绍
  6. react-redux的connect()方法
  7. ARP协议(1)什么是ARP协议
  8. PCB板布线中地线和电源线的布线规则
  9. C#基础关键字
  10. shell tr命令的使用