2016-03-19 10 views
4

私のタイスクリプトファイルをコンパイルするビジュアルスタジオコードにこのタスクがあります。 1つのフォルダにすべてのタイプスクリプトを追加し、別のフォルダにすべてのJavaScriptを追加することで、よりクリーンなファイル構造にしたいと考えています。そうするために私の仕事の議論をどのように変えるのですか?現在のコードでは、出力がtypescriptと同じフォルダにコンパイルされます。現在のコードは次のとおりです。出力ディレクトリを指定してVisual Studioのコードタスクでtypescriptをコンパイルします

{ 
    "version": "0.1.0", 

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 
    "command": "tsc", 

    // The command is a shell script 
    "isShellCommand": true, 

    // Show the output window only if unrecognized errors occur. 
    "showOutput": "silent", 

    // args is the HelloWorld program to compile. 
    "args": [ 
     "scripts/front_end/view_models/search_filter_view_model.ts", 
     "scripts/front_end/models/area_getter.ts", 
     "scripts/front_end/bootstrap_app.ts", 
     "scripts/front_end/models/category.ts", 
     "scripts/front_end/plugins/slideshow.ts" 
    ], 

    // use the standard tsc problem matcher to find compile problems 
    // in the output. 
    "problemMatcher": "$tsc" 
} 

答えて

4

あなたのプロジェクトで何が起こっているのかよくわかりません。しかし、ここでは私の角度のプロジェクトに使用されている私のtsconfig.jsonで使用しているものです。これをプロジェクトのサンプルとして使用し、それに応じて変更することもできます。 outDiroutFileは私が推測する必要があります。

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "system", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": true, 
    "noImplicitAny": false, 
    "outDir":"client/build/", 
    "outFile": "client/build/all.js", 
    "declaration": true 
    }, 
    "exclude": [ 
    "node_modules", 
    "server" 
    ], 
    "include": [ 
     "client/*.ts", 
     "client/**/*.ts", 
     "client/**/**/*.ts" 
    ] 
} 

// Include all folders to put to a file. 
/* "outDir":"client/build/", 
    "outFile": "client/build/all.js" */ 
+0

ありがとうございました。 outDirはjsファイルが入っているディレクトリですか? tsファイルから来たすべてのjが1つのファイル(client/build/all.js)に入れられていますか?あなたのjsはすべてclient/build/all.jsにありますか? – BeniaminoBaggins

+0

'outDir'はすべてのjsファイルのビルドが行われるディレクトリです。' outFile'はほぼ同じですが、違いはバンドル(すべてのjsファイル)ファイル名が含まれている点です。これは、 'include'セクション内に記述されたtsファイルから変換されたすべてのjsファイルを含みます。 tsconfig.jsonファイルのパスは、前述のフォルダパスからの相対パスです。コンパイル時にチェックしてください。 – Gary

関連する問題