YUI的COM pressor和.NET应用程序应用程序、COM、YUI、NET

2023-09-04 01:34:30 作者:情咒°

我想用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:

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

在调试模式下, 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.

 
精彩推荐
图片推荐