How to configure Visual Studio to combine all TypeScript files into a single JavaScript file?

Using the tsc command is as simple as running:

tsc --out all.js js/*.ts 

How can I configure Visual Studio for this when I create my project?

+6
source share
3 answers

Just received. Add this line:

 <Exec Command="tsc --out all.js @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" /> 

in BeforeBuild target .csproj or .vbproj , for example:

 <Target Name="BeforeBuild"> <Message Text="Compiling TypeScript files" /> <Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" /> <Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" /> <Exec Command="tsc --out all.js @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" /> </Target> 
+2
source

I found a potentially simple solution by simply changing the project assembly properties (.csproj / .vbproj) that you are creating:

Project Build Typescript Settings

I do not know in which version of Typescript this function appeared. But it is much simpler than svallory solution

Source: http://rostacik.net/2013/12/18/how-to-setup-post-build-event-in-visual-studio-to-combine-multiple-typescript-files-to-one-javascript- file /

EDIT . Starting with Visual Studio 2015, it is now very easy to integrate Grunt / Gulp tasks and run them in your builds. I personally really like to use Gulp for more granular control over the files that I build and / or reduce, and I highly recommend it. Using this guide as a starting point should help.

+3
source

It looks like the proposed solution is for typescript 0.8.1.1, not 0.8.2

+1
source

All Articles