Search code examples
visual-studio-2012typescripttsc

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


Using tsc command it's as easy as running:

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

How can I configure Visual Studio to do that when I build my project?


Solution

  • Just got it. Add this line:

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

    to the BeforeBuild target of your .csproj or .vbproj file, like this:

    <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>