YUI的COM pressor和.NET应用程序 [英] YUI Compressor and .NET Apps

查看:143
本文介绍了YUI的COM pressor和.NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用YUI的COM pressor(原件),并把它作为典型的MS构建过程(Visual Studio 2008中,M​​SBuild的)的一部分。

I want to use YUI Compressor (the original) and use it as part of typical MS build processes (Visual Studio 2008, MSBuild).

有没有人对此有什么指导意见或想法?例如,对于并入项目的好方法,做与现有的CSS和JS参考,并像什么。

Does anyone have any guidance or thoughts on this? For example, good ways for incorporating into project, what to do with existing CSS and JS references, and the like.

我很高兴听到YUI的COM pressor ​​.NET和替代的好处,但我更感兴趣的是利用原有的。

I am happy to hear on the benefits of YUI Compressor .NET and alternatives but I'm more interested in use of the original.

谢谢 斯科特

推荐答案

我同时使用。 YUI的COM pressor是命令行,且易于集成到任何的构建过程。我得到了它在运行耙,没有任何问题。

I use both. The YUI compressor is command-line, and easy to integrate into any build process. I got it running in rake with no problems.

这可能是最常见的执行的JavaScript / CSS COM pression就地当你部署。这样,你就不必更新JS参考。但我用我的网站上的另一种方法。我创建为COM pressed文件 * - min.js 等。要包括在我的网页脚本或CSS文件,我调用服务器端的方法

It's probably most common to perform the javascript/css compression in-place when you deploy. That way you don't have to update JS references. But I'm using another method on my site. I have the compressed files created as *-min.js, etc. To include a script or css file on my page, I call a server-side method:

<%= ScriptSrc("~/assets/myscript.js") %>
<%= LinkSrc("~/assets/main.css") %>

这些方法执行以下操作:

These methods do the following:

  1. 展开应用程序相对路径
  2. 添加版本字符串末尾(缓存失效)
  3. 完整剧本,这取决于我们是否在调试模式或不缩小的版本之间进行选择。

在调试模式下, ScriptSrc 可能输出是这样的:

In debug mode, ScriptSrc might output something like this:


<script type="text/javascript" src="http://stage.myapp.com/assets/myscript.js?v=1.2" ></script>

但在生产中会加载精缩版:

but in production it would load the minified version:


<script type="text/javascript" src="http://stage.myapp.com/assets/myscript-min.js?v=1.2" ></script>

一个这样做的好处是,我可以充分和缩小的版本之间切换,只需通过改变的web.config ,它可以帮助调试。

One of the benefits of this is that I can switch between the full and minified versions just by changing the web.config, which can aid debugging.

这篇关于YUI的COM pressor和.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆