NestJS 阻止服务器在开发中重新加载

Geo*_*tan 2 node.js nestjs

我有一条路线,在public目录中创建一个新文件夹,该文件夹是由app.useStaticAssets提供的静态内容。

问题是,即使我在tsconfig.build.jsontsconfig.json排除数组中添加了公共目录,当在公共目录中删除或创建新文件夹时,我的服务器仍然会在开发中重新加载。

我错过了什么?

更新: tsconfig.json

{
 "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": ["node_modules", "dist", "public"]
}
Run Code Online (Sandbox Code Playgroud)

我提到public文件夹位于src文件夹之外。他们处于同一水平。

eol*_*eol 5

我能够重现此问题,并发现这似乎是一个常见问题 - > https://github.com/nestjs/nest/issues/3510

正如 github 问题中所提出的,添加include作为解决方法似乎可以解决问题:

{
 "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist", "public"]
}
Run Code Online (Sandbox Code Playgroud)