最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Use TypeScript in ASP.NET MVC - Stack Overflow

programmeradmin7浏览0评论

How to effectively use TypeScript with ASP.NET MVC?

I want my IDE to do the following actions when I run my project:

  1. Compile (interpret) my typescript files (*.ts) by typescript piler.
  2. Minimize all the javascript files.
  3. Obviously run my app :).

How to configure IDE to do all the steps automatically on startup?

How to effectively use TypeScript with ASP.NET MVC?

I want my IDE to do the following actions when I run my project:

  1. Compile (interpret) my typescript files (*.ts) by typescript piler.
  2. Minimize all the javascript files.
  3. Obviously run my app :).

How to configure IDE to do all the steps automatically on startup?

Share Improve this question edited Sep 20, 2015 at 3:50 Andrei asked May 2, 2013 at 9:45 AndreiAndrei 44.7k39 gold badges162 silver badges226 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6 +50

At this address, you will find that the current preview version of TypeScript is not providing a project template for ASP.NET MVC 4 projects. But you can edit your csproject file with the following code:

<ItemGroup>

    <TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />

</ItemGroup>

  <Target Name="BeforeBuild">

   <Exec Command="&amp;quot;$(PROGRAMFILES)\

   Microsoft SDKs\TypeScript\0.8.0.0\tsc&amp;quot; 

  @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />

  </Target>

It allows you to pile all TypeScript when building ASP.NET MVC 4 project.

About the optimizing :

I suggest you separate the JavaScript files of your project and add references them into your master page like at this post : How can I automatically press and minimize JavaScript files in an ASP.NET MVC app?.

You can also use the "bundling" with the Razor view. Personally I use that and it works perfectly.

发布评论

评论列表(0)

  1. 暂无评论