需要 - Visual Studio自定义构建操作以缩小JS和CSS

Cha*_*ell 13 compression minify visual-studio-2010 combres

我一直在我的应用程序中使用Combres在运行时压缩,组合和缩小我的javascript和css.这非常有效并且完美地满足YSlow.

现在我出于性能原因重新思考整个过程,我更考虑在构建时而不是运行时完成所有这些.

我希望我能在没有太多麻烦的情况下就如何做到这一点得到一些建议.是否存在可以满足我需要的现有工具(类似于Combres)?

Edu*_*eni 13

认识Chirpy

替代文字

Chirpy Mashes,缩小并验证您的javascript,样式表和无点文件.

Chirpy很傻.使用Google Closure Tools或YUI Compressor for .Net来缩小和混合您所有的宝贵资产.它很简单,灵活,而且是自动的.

有关此处CodePlex网站的更多信息

  • Chirpy太神奇了!:d (4认同)
  • 我改变了接受因为chirpy确实令人惊讶. (2认同)

Cha*_*ell 2

我最初使用Chirpy进行捆绑,但后来转移到BundlerBundler允许我相对轻松地将所有内容完美地连接到一个性感的构建文件(powershell)中。我个人已经不再使用 Visual Studio 构建事件,而是开始在独立环境中运行构建。这对我处理诸如GithubTeam City持续集成 (CI)之类的事情很有帮助。

这是您的构建文件“可能”的样子。(注意可能无法完全运行,未经测试)


构建.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
Run Code Online (Sandbox Code Playgroud)