【VSCode】调试grunt任务

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/greatbody/article/details/54646875

前言

废话不多说, grunt 是一个很好的自动化任务运行器,但是由于它本身不是项目文件,所以不是很确定如何调试。

今天的尝试很好的开了个头,以后的涉及 grunt 的任务就都可以这样调试了。

技术基础

VSCode基于NodeJS构建,天生支持JS的调试,而Grunt又是js的,所以,可以调试。

配置模板

{
  // Use IntelliSense to learn about possible Node.js debug attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "启动程序",
      "program": "${workspaceRoot}\\node_modules\\grunt-cli\\bin\\grunt",
      "cwd": "${workspaceRoot}"
    },
    {
      "type": "node",
      "request": "attach",
      "name": "附加到进程",
      "port": 5858
    }
  ]
}

下断点

我们知道, Grunt 命令运行后, Grunt 将会加载运行项目根目录的 Gruntfile.js 这个文件。那么如果需要下断点的话,请从这个文件开始下,一定可以命中。

联系作者

Email: [email protected]

猜你喜欢

转载自blog.csdn.net/greatbody/article/details/54646875