如何为不同的目录设置不同的目标

如何为不同的目录设置不同的目标

问题描述:

我必须目录 /src/server/src/client 用于后端和前端代码.

I have to directories /src/server and /src/client for the backend and frontend code.

在后端,我想将我的 .ts 源定位到 es2017 javascript.在客户端中,我想将 .ts 源定位到 es5.我如何向 Visual Studio Code 表明这一点?

In the backend I want to target my .ts sources to es2017 javascript. In the client I want to target the .ts sources to es5. How can I indicate that to the Visual Studio Code?

我尝试在每个目录中放置两个不同的 tsconfig.json.但是 Visual Studio Code 只需要根 tsconfig.json.

I try to put two different tsconfig.json in each directory. But the Visual Studio Code only takes the root tsconfig.json.

您可以有两个 tsconfig.json 文件,一个用于客户端,另一个用于服务器,然后使用 tsc 编译每个文件 带有 -p 标志,例如:

You can have two tsconfig.json files, one for client and the other for server and then compile each using tsc with -p flag, e.g.:

tsc -p /src/server && tsc -p /src/client