最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Typescript: Make tsconfig emit one folder but not the other folder - Stack Overflow

programmeradmin1浏览0评论

I'm converting an existing project from js to typescript. I want to be able to set noEmit = true on one folder but have the other folder have noEmit = false.

The reason is that I have my client(angular) code set up through webpack and do not need typescript to generate the javascript for me. While the server (Node/express) still needs to be generated into javascript.

I've tried a few different binations but haven't seem to find the right way to do it.

My only solution that I've been able to get to work is having two tsconfig.json and running a mand like tsc -p src\server\tsconfig && tsc -p src\client\tsconfig

I realize that this is not a good solution, but I have not gotten a single tsconfig to work nor having a base tsconfig.

Here is the folder structure..

|-Src
|--/client
|--/server

Is there a way to achieve this using a single tsc mand? Or is there a better way I should be formatting the project? Thanks!!

I'm converting an existing project from js to typescript. I want to be able to set noEmit = true on one folder but have the other folder have noEmit = false.

The reason is that I have my client(angular) code set up through webpack and do not need typescript to generate the javascript for me. While the server (Node/express) still needs to be generated into javascript.

I've tried a few different binations but haven't seem to find the right way to do it.

My only solution that I've been able to get to work is having two tsconfig.json and running a mand like tsc -p src\server\tsconfig && tsc -p src\client\tsconfig

I realize that this is not a good solution, but I have not gotten a single tsconfig to work nor having a base tsconfig.

Here is the folder structure..

|-Src
|--/client
|--/server

Is there a way to achieve this using a single tsc mand? Or is there a better way I should be formatting the project? Thanks!!

Share Improve this question edited Dec 19, 2018 at 23:08 Flyii 1,1552 gold badges12 silver badges21 bronze badges asked Dec 19, 2018 at 17:08 gmoneygmoney 3651 gold badge5 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

I don't think there's another solution besides having multiple tsconfig.json files like you're already doing, as per this answer and this ment.

You can make this a little more streamlined by having a tsconfig.json for pilation and a separate tsconfig-build.json that you use in your package.json for building, i.e.:

// package.json
{
    "scripts": {
        "build": "tsc -p tsconfig-build.json"
    },
    // ...
}

With this setup (assuming the default tsconfig.json is in your root), running tsc from the mand line will use the default tsconfig.json, but running npm run build will use tsconfig-build.json. You can also have one tsconfig extend from another, so if you have a lot of options in mon, you could add a tsconfig-base.json that both configs extend from.

You can probably achieve what you want with the exclude property in your tsconfig.json file.

Check the documentation for the exclude property

发布评论

评论列表(0)

  1. 暂无评论