在后台使用 npm watch 文件以启用与 Visual Studio Task Runner 的集成

Ste*_*t_R 5 watch visual-studio npm .net-core task-runner-explorer

我正在尝试让 npm 监视客户端代码中的文件更改。我可以让它从命令行正常工作,但我真的很喜欢它在 Visual Studio 任务运行器中工作。

我的 package.json 看起来像这样:

...
"watch": {
  "compile": {
  "patterns": [
      "wwwroot"
    ],
    "extensions": "ts"
  }
},
"scripts": {
  "prebuild": "copyfiles -f ./node_modules/d3/build/*.js ./wwwroot/lib/d3",
  "compile": "tsc && browserify ./wwwroot/app/app.js -o ./wwwroot/bundle.js",
  "build": "npm run compile",
  "watch": "npm-watch"
},
...
Run Code Online (Sandbox Code Playgroud)

所以从命令行运行npm run build然后npm run watch一切都按预期运行。

然而,当我使用 Task Runner 将我的监视脚本绑定到 After Build 事件时,如下所示:

任务运行器屏幕截图

它永远不会“退出”,因此,构建永远不会完成*,Visual Studio 会在应用程序运行之前等待我终止任务。有没有办法让脚本在后台或某种“分离”模式下运行,使 Visual Studio 能够完成构建并运行应用程序?

我尝试使用不同的手表工具,但在其中任何一个中都找不到任何此类选项。

*实际上,我猜构建本身可能确实完成了,但 VisualStudio 从不运行应用程序,只是挂起等待脚本退出。

Rak*_*ula 2

将手表绑定更改为项目打开。然后项目打开后就会开始观看。