简体   繁体   English

Visual Studio 2012:将更多TypeScript文件编译为一个JavaScript文件

[英]Visual Studio 2012: compile more TypeScript files to one JavaScript file

Is it possible to set a "compiler" option to compile more TypeScript files in one project to one JavaScript file? 是否可以设置“编译器”选项以将一个项目中的更多TypeScript文件编译为一个JavaScript文件? The only solution I can find is passing multiple files to the "tsc" manually by hand, but I'd like to use the features of the IDE Visual Studio 2012. 我能找到的唯一解决方案是手动将多个文件手动传递到“ tsc”,但是我想使用IDE Visual Studio 2012的功能。

I am using bundling to do this in ASP.NET. 我在ASP.NET中使用捆绑进行此操作。 You can use bundling with MVC or Web Forms. 您可以将捆绑与MVC或Web窗体一起使用。

If you are using Web Essentials, you will already be getting both a .js and a .min.js and bundling is clever enough to use the .js files at debug time and the minified versions in production - so you can debug easily but get smaller files in live. 如果您使用的是Web Essentials,则将同时获得.js.min.js并且捆绑程序足够聪明,可以在调试时使用.js文件,并在生产环境中使用.min.js版-因此您可以轻松调试,但可以较小的文件。

You can read all about Bundling and Minification on the ASP.NET site . 您可以在ASP.NET网站上阅读有关捆绑和缩小的所有信息。

However, if you want TypeScript to bundle the file (it won't minify it) you just need to use the following flag: 但是,如果您希望TypeScript捆绑文件(不会缩小文件),则只需使用以下标志:

tsc --out combined.js app.ts

TypeScript will walk the dependencies and sort out the ordering for you so all you need to worry about is minifying the combined file. TypeScript将遍历依赖关系并为您整理顺序,因此您所需要担心的就是缩小组合文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM