简体   繁体   English

Visual Studio中的Javascript和CSS资产打包

[英]Javascript and CSS Asset Packaging in Visual Studio

I have several backbone.js views, javascript modules and style sheets in an ASP.Net MVC app i'm developing. 我正在开发的ASP.Net MVC应用程序中有几个backbone.js视图,javascript模块和样式表。 I want to seperate these files during development but combine/consolidate, compress, uglify, resolve dependencies etc. before deployment. 我想在开发期间分离这些文件,但在部署之前组合/合并,压缩,uglify,解决依赖关系等。 The Ruby community has solutions for this including Juicer and Jammit . Ruby社区为此提供了解决方案,包括JuicerJammit Are there similar solutions for .Net web developers ideally solutions that integrate with visual studio. 是否有针对.Net Web开发人员的理想解决方案与Visual Studio集成的类似解决方案。

We use YUI Builder for exactly this purpose. 我们使用YUI Builder来达到这个目的。 (We also happen to use YUI extensively in our products.) It's Java/Ant based, but it wasn't hard to get msbuild to do all the work by creating a project file (csproj in our case) and overriding the "build" target. (我们也碰巧在我们的产品中广泛使用YUI。)它是基于Java / Ant的,但是通过创建项目文件(在我们的例子中是csproj)并覆盖“构建”来让msbuild完成所有工作并不难。目标。 We include the project in our main .sln file, and it automatically builds along with all of our C#/.NET projects. 我们将项目包含在主.sln文件中,并自动与所有C#/ .NET项目一起构建。

One thing to watch out for: We initially got frequent/random "access denied" errors when building this way. 需要注意的一点是:我们最初在构建这种方式时会出现频繁/随机的“访问被拒绝”错误。 It turns out that Visual Studio was locking many of the intermediate files that YUI Builder generates. 事实证明,Visual Studio正在锁定YUI Builder生成的许多中间文件。 So our workaround is to robocopy all the relevant files to a temp folder, do the work there, and robocopy them back. 因此,我们的解决方法是将所有相关文件复制到临时文件夹,在那里完成工作,然后将其复制回来。

It's not ideal, and certainly not an out-of-the-box integration like you're probably hoping for, but it works well for us. 它并不理想,当然不是像你希望的那样开箱即用的集成,但它对我们很有用。 It gives us minification, JSLint checking, dependency management, and an infrastructure for serving one combined file rather than individual scripts. 它为我们提供了缩小,JSLint检查,依赖关系管理以及用于提供组合文件而非单个脚本的基础结构。

I've used Chirpy for this in the past. 我过去曾经使用过Chirpy Also compiles SASS, LESS, and CoffeeScript. 还编译SASS,LESS和CoffeeScript。

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

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