排除在TypeScript中监视目录

问题描述 投票:0回答:2

--watch是开发过程中的一项巧妙功能。但是,在我的应用程序中,我将文件上传到名为tmp的目录中。每当文件上传到此目录时,我的应用程序都会重新编译,这会导致各种问题。我想从观看中排除tmp

到目前为止,我尝试将tmp添加到"exclude":中的tsconfig.json属性中,但这无济于事。

我已经查看了文档,但是找不到有关如何执行此操作的任何信息。 https://www.typescriptlang.org/docs/handbook/configuring-watch.html

我正在努力实现的目标吗?

typescript
2个回答
0
投票

我实际上在tsconfig上使用了排除方法,如下所示:

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "preserveConstEnums": true,
    "strict": true,
    "target": "es2017",
    "baseUrl": ".",
  },
  "exclude": ["__tests__"]
}

当我更改__tests__文件夹中的任何文件时,将不会以监视模式再次编译。

注意:我使用的是最新的tsc


0
投票

根据Microsoft,我要实现的目标是不可能的。 tsc -w should not recompile if a file is created into an excluded folder

© www.soinside.com 2019 - 2024. All rights reserved.