ts运行配置.md

// tsconfig.json

outDir: "./build"; // 打包编译后的文件放置位置

安装:

npm install nodemon -D

配置:

//package.json

"scripts": {
  build: "tsc -w"; // w: 改变代码时自动编译代码:
  start: "nodemon node ./build/xxx.js"; //改变代码时自动运行代码:
}

// 忽略某些文件下的改变,即它改变时不触发自动运行与自动编译

"nodemonConfig" : {
  "ignore": [
    "data/*"
  ]
}

优化:使用 npm run dev,即可并行运行 build 和 start

使用 concurrently,

安装:

npm install concurrently -D

// package.json

"scripts": {
  "dev:build": "tsc -w",
  "dev:start": "nodemon node ./build/xxx.js",
  "dev": "concurrently npm:dev:*" // 并行执行build和start
}
posted @ 2022-05-07 13:01  sinceForever  阅读(86)  评论(0编辑  收藏  举报