我目前有两个脚本:
"scripts": {
"build": "tsc -p . -w",
"watchjs": "nodemon dist/index.js"
}
我需要两个终端,一个用于构建 watchjs,我想将这两个脚本组合成一个脚本,以便在检测到更改后自动构建并在构建后运行它!
我试过类似的东西:
"start": "tsc -p . -w && node dist/index.js",
但显然
tsc -w
永无止境,因此我不能在构建完成后直接调用命令!
假设您的系统是 Windows(对于以下解决方案,您需要 concurrently 包作为 devDependency)
"serve": "concurrently \"tsc -w\" \"nodemon dist/index.js\""
祝你好运!