VSCode tasks.json:找不到preLaunchTask

时间:2017-10-14 21:24:19

标签: visual-studio-code

我有一个多根项目:React客户端和TypeScript Express服务器,如下所示:

.vscode
    launch.json
    tasks.json
client
    src
    package.json
    ...
server
    dist
    src
        server.ts
    package.json
    tsconfig.json
    webpack.config.js
    yarn.lock

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Server",
      "program": "${workspaceFolder}/server/src/server.ts",
      "outFiles": [
        "${workspaceFolder}/server/dist/**/*.js"
      ],
      "preLaunchTask": "build",
      "sourceMaps": true
    }
  ]
}

Tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "npm",
      "identifier": "build",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "path": "${workspaceFolder}/server"
    }
  ]
}

这个相同的配置适用于另一个package.json在workspaceFolder中的项目。我认为path会起作用,但我会Could not find the preLaunchTask 'build'

显然,在我的server/package.json中,我有以下内容:

"scripts": {
  "build": "yarn clean && webpack",
  ...
},

1 个答案:

答案 0 :(得分:0)

Try to copy the .vscode folder to the server subfolder:

...
client
  ...
server
  .vscode
    launch.json
    tasks.json
  ...