1 下载安装node.js后,执行 npm install grunt 安装好了grunt
2 分别 执行 npm install grunt-contrib-jshint
npm install grunt-contrib-uglify 压缩混淆工具
npm install grunt-contrib-concat 合并多个文件工具
npm install grunt-contrib-watch 监事文件更改工具
可以参考http://www.gruntjs.net/sample-gruntfile
下面以运行grunt concat 来说明
[img]http://dl2.iteye.com/upload/attachment/0108/2821/d8f1eb0a-039c-3503-bafb-4bfb142ee97d.png[/img]
在node.js下面新建cd目录(由src指定) 然后将要合并的js文件放入其中 分隔符我选的是//,运行grunt concat 会自动执行并压缩为一个文件并放入指定是dist文件夹中pkg.name 中,它由pakage文件来配置 注意 即使没有cd目录 仍务也不会报错 只不过生成到dist中的是一个空js文件 任务结果如图
[img]http://dl2.iteye.com/upload/attachment/0108/2827/dff2e95d-663f-3f77-b82c-a253fdde45e1.png[/img]
2 分别 执行 npm install grunt-contrib-jshint
npm install grunt-contrib-uglify 压缩混淆工具
npm install grunt-contrib-concat 合并多个文件工具
npm install grunt-contrib-watch 监事文件更改工具
可以参考http://www.gruntjs.net/sample-gruntfile
下面以运行grunt concat 来说明
[img]http://dl2.iteye.com/upload/attachment/0108/2821/d8f1eb0a-039c-3503-bafb-4bfb142ee97d.png[/img]
在node.js下面新建cd目录(由src指定) 然后将要合并的js文件放入其中 分隔符我选的是//,运行grunt concat 会自动执行并压缩为一个文件并放入指定是dist文件夹中pkg.name 中,它由pakage文件来配置 注意 即使没有cd目录 仍务也不会报错 只不过生成到dist中的是一个空js文件 任务结果如图
[img]http://dl2.iteye.com/upload/attachment/0108/2827/dff2e95d-663f-3f77-b82c-a253fdde45e1.png[/img]