我想并行运行 2 个 npm 脚本,但此 VS Code 仅运行第一个任务并停在那里。我该如何解决?
我的 tasks.json
如下:
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"suppressTaskName": true,
"args": [
"run"
],
"tasks": [
{
"args": [
"gulp"
],
"taskName": "gulp",
"isBuildCommand": true
},
{
"args": [
"babel"
],
"taskName": "babel",
"isBuildCommand": true
}
]
}
最佳答案
在 Windows 上,NPM package "concurrently"可能对你有帮助。
在 package.json
中:
"scripts": {
"gulpbabel": "concurrently \"npm run gulp\" \"npm run babel\""
},
然后在 tasks.json
中:
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "gulpbabel",
"isBackground": true,
"problemMatcher": [
"create_one_for_gulp",
"create_another_for_babel",
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
理想情况下(但不是必需的),您还需要创建两个 problem matchers :一个用于 gulp
任务,一个用于 babel
。他们应该能够从合并的输出中提取错误详细信息,并检测相应任务的观察者何时触发/停止(以便 VS Code 可以在状态栏中显示旋转的“\”)。
关于npm - 如何在 VS 代码中运行 2 个监视任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35742496/