Grunt 插件开发与调式

1 grunt是什么

官方网站解释的很清楚,http://gruntjs.com/ http://gruntjs.cn/

它是一种javascript任务运行器,对于需要反复重复的任务,例如压缩、编译、单元测试、代码检查等,自动化工具可以减轻你的劳动,简化你的工作。

grunt的安装请参考官方文档。

2 grunt 插件开发步骤

  1. Install grunt-init with npm install -g grunt-init
  2. Install the gruntplugin template with git clone git://github.com/gruntjs/grunt-init-gruntplugin.git ~/.grunt-init/gruntplugin
  3. Run grunt-init gruntplugin in an empty directory.
  4. Run npm install to prepare the development environment.
  5. Author your plugin.
  6. Run npm publish to publish the Grunt plugin to npm!

3 使用webstorm调试

WebStrom是由jetbrains开发的javascript IDE,是付费的,功能非常强大。

1,首先要确定安装了nodejs

2,打开webstrom,并open上述构建好的项目目录

3,工具栏Run—> Edit configrations

QQ截图20140806141759

4,点击绿色图标,选择Node.js

其中Javascript file: 要选择grunt程序,而不是Gruntfile.js

Application parameters: test,表示启动 grunt test 这个命令。

 

QQ图片20140806142925

至此就可以对gurnt进行debug运行了。

posted @ 2014-08-06 14:39  pairwinter  阅读(836)  评论(0编辑  收藏  举报