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

发布于 2024-09-26 05:01:30 字数 354 浏览 8 评论 0 原文

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

现在,出于性能原因,我正在重新考虑整个过程,并且我更倾向于考虑在构建时而不是运行时执行所有这些操作。

我希望我能得到一些关于如何做到这一点的建议,而不会有太多麻烦。是否有现有的工具(类似于 Combres)可以满足我的需要?

I've been using Combres in my applications to compress, combine and minify my javascript 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

书间行客 2024-10-03 05:01:30

认识一下 Chirpy

alt text

Chirpy 混合、缩小并验证您的 JavaScript、样式表和无点文件。

Chirpy 很活泼。使用 Google Closure Tools 或 YUI Compressor for .Net 来缩小和混合您的所有宝贵资源。它很简单、灵活并且是自动的。

更多信息此处CodePlex 网站

Meet Chirpy

alt text

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

浪漫之都 2024-10-03 05:01:30

MSBuild 社区任务项目有一个 JSCompress 任务。在此处查看该项目:http://msbuildtasks.tigris.org/

这是有关如何实际实施的另一个资源此任务: http://www.justise .com/2007/04/20/javascript-and-css-compression-in-msbuild/

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/

瞎闹 2024-10-03 05:01:30

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

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


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

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
花辞树 2024-10-03 05:01:30

您还可以查看 ajaxtoolkit 他们有 2 个用于压缩 JS 的任务。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文