:
{
"compilerOptions": {
"module": "commonjs",
"outDir": "dist"
},
"exclude": [
"node_modules",
"dist",
"typings/browser.d.ts",
"typings/browser/**"
]
}
このテストやアプリのjsファイルを混合せずに「DIST」フォルダに元の構造を保持します複数の設定ファイルを使用し、簡略化するためにextends
を使用してください。
は、私は2つのファイルがあるとしましょう:tsconfig.json
とtsconfig.build.json
// tsconfig.json
{
...
"exclude": [...]
}
// tsconfig.build.json
{
...
"files": [ "typings/index.d.ts", "src/index.ts" ]
}
をこのように、私は(tsc -p tsconfig.build.json
を使用して)を構築するためにどのように微調整することができ、何ts language service
(IDE)のハンドル。
更新:私のプロジェクトが成長するにつれて、より多くの設定ファイルがあることになりました。私は活字体で使用できるようになりました「拡張」機能を使用する:これは、あなたが使っているものは何でもテストフレームワークに多少依存しますが、私は私のテストファイルをコンパイルするts-nodeを使用したい
// tsconfig.base.json
{
// your common settings. Mostly "compilerOptions".
// Do not include "files" and "include" here,
// let individual config handles that.
// You can use "exclude" here, but with "include",
// It's pretty much not necessary.
}
// tsconfig.json
{
// This is used by `ts language service` and testing.
// Includes source and test files.
"extends": "./tsconfig.base.json",
"atom": { ... },
"compilerOptions": {
// I set outDir to place all test build in one place,
// and avoid accidentally running `tsc` littering test build to my `src` folder.
"outDir": "out/spec"
}
"include": [ ... ]
}
// tsconfig.commonjs.json or tsconfig.systemjs.json or tsconfig.global.json etc
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
// for some build this does not apply
"declaration": true/false,
"outDir": "dist/<cjs, sys, global, etc>",
"sourceRoot": "..."
},
// Only point to typings and the start of your source, e.g. `src/index.ts`
"files": [ ... ],
"include": [ ... ]
}
複数の設定ファイルに分かれていないと、パッケージに特別な(テスト)ファイルを配布するという欠点があります。また、あなたの2つの 'include 'は冗長です。 'src/**/*。ts'だけが必要です。 – unional
btw、' typings/*** 'のように' *** 'とは何ですか?聞いたことがない。 – unional
'**'にする必要があります。 – barndog