本文介绍了如何配置 Visual Studio 将所有 TypeScript 文件合并为一个 JavaScript 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 tsc 命令就像运行一样简单:

Using tsc command it's as easy as running:

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

如何在构建项目时配置 Visual Studio 以执行此操作?

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

推荐答案

刚搞定.添加这一行:

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

.csproj.vbproj 文件的 BeforeBuild 目标,如下所示:

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>

这篇关于如何配置 Visual Studio 将所有 TypeScript 文件合并为一个 JavaScript 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 10:12