开发者

Needed - Visual Studio Custom Build Actions To Minify JS and CSS

I've been using Combres in my applications to compress, combine and minify my ja开发者_如何学Cvascript and css at run time. This works extremely well and satisfies YSlow perfectly.

Now I'm rethinking the whole process for performance reasons, and I'm more so thinking about doing all of this at build time instead of run time.

I'm hoping that I can get a little advice on how to do this without too much hassle. Is there an existing tool (similar to Combres) that can do what I need?


Meet Chirpy

Needed - Visual Studio Custom Build Actions To Minify JS and CSS

Chirpy Mashes, minifies, and validates your javascript, stylesheet, and dotless files.

Chirpy is chippy. Use Google Closure Tools or YUI Compressor for .Net to minify and mash all of your precious assets. It's easy, it's flexible, and it's automatic.

More info here or on the CodePlex site


The MSBuild Community Tasks Project has a JSCompress task. Check out the project here: http://msbuildtasks.tigris.org/

Here's another resource on how to actually implement this task: http://www.justise.com/2007/04/20/javascript-and-css-compression-in-msbuild/


I originally used Chirpy to do my bundling, but have since moved over to Bundler. Bundler allows me to wire everything up nicely in a sexy build file (powershell) with relative ease. I've personally moved away from Visual Studio Build events, and started running the builds in a stand alone environment. This helps me with things like Github to Team City Continuous Integration (CI).

Here's what your build file "could" look like. (note might not fully run, this is untested)


build.ps1

# Set up varriables for build script
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$BundlerDir = "$directorypath\build_tools\bundler\"
$AppRoot = "$directorypath\SomeApp.Web\"   
$ScriptsDir = "scripts\"                                   
$CssDir = "css\"                  

# Run Bundler to Combine and Minify
&($BundlerDir + "node.exe") ( $BundlerDir + "bundler.js") ($AppRoot +$CssDir) ($AppRoot + $ScriptsDir)

# Everything else...
#    Clean the bins
#    Build the projects
#    Run the tests


You could also take at look at ajaxtoolkit they have 2 tasks for compression of JS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜