Empaquetado de activos JavaScript y CSS en Visual Studio

I have several backbone.js views, javascript modules and style sheets in an ASP.Net MVC app i'm developing. I want to seperate these files during development but combine/consolidate, compress, uglify, resolve dependencies etc. before deployment. The Ruby community has solutions for this including exprimidor y Jammit. Are there similar solutions for .Net web developers ideally solutions that integrate with visual studio.

preguntado el 09 de marzo de 12 a las 15:03

2 Respuestas

He usado Alegre for this in the past. Also compiles SASS, LESS, and CoffeeScript.

respondido 09 mar '12, 16:03

Utilizamos YUI Builder for exactly this purpose. (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. We include the project in our main .sln file, and it automatically builds along with all of our C#/.NET projects.

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

respondido 09 mar '12, 16:03

Thanks for the solution. It is not as streamlined as I was looking for as I prefer not to solve such a common problem with a custom solution. I am looking for an existing and proven solution. - Atenas Holloway

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.