2016-04-05 43 views
1

假設我們有以下文件:如何編譯擴展名爲* .server.ts的所有文件?

/mymodule1/ 
    main.server.ts 
    main.client.ts 

/mymodule2/ 
    main.server.ts 
    main.client.ts 

我們如何只編譯所有的* .server.ts文件,但離開* .client.ts文件保持原樣?

我想這樣的事情在我的tsconfig.json但它失敗:

tsconfig.json,使用TSC CLI時:

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "sourceMap": true 
    }, 
    "files": [ 
     "**/*.server.ts" 
    ] 
} 

[編輯]

或類似的東西:

tsconfig.json,使用時:

{ 
     "compilerOptions": { 
      "target": "es5", 
      "module": "commonjs", 
      "sourceMap": true 
     }, 
     "filesGlob": [ 
      "**/*.server.ts" //seams to work, but Atom complains that the other files are not added to the compile context. 
     ], 
     "exclude": [ 
      "**/*.client.ts", //fails, as well as in files 
      "typings", 
      "node_modules" 
     ] 

    } 

是否有filesExcludeGlob

回答

0

tsconfig.json

tsconfig.json不支持水珠files本身。

也就是說原子打字稿支持它https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#filesglob,咕嚕-TS支持的話:https://github.com/TypeStrong/grunt-ts

所以你不能只tsc做它本身。

是否有filesExcludeGlob

只需使用否定:

"filesGlob":[ 
    "**/*.server.ts", 
    "!**/**.client.ts", 
] 
+0

謝謝您的回覆! 我應該提到我已經用Atom和tsc cli嘗試過了。 你喜歡提供一個工作示例嗎?哪個工具無關緊要。 – daslicht

相關問題