我有一个多根项目: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",
...
},
答案 0 :(得分:0)
Try to copy the .vscode folder to the server subfolder:
...
client
...
server
.vscode
launch.json
tasks.json
...