1

目前,我一直在尝试将 Cassette 放入我们的 Sitecore 项目中,但它只是失败了。我已经在项目中使用了 dotLess,但想要一个更可靠的解决方案,用于捆绑时的缓存清除。

我可以在普通的 .Net4 项目中使用 Cassette,但无法在我们的 Sitecore 项目中使用它。(Ed) 我们无法让它实际构建任何类型的捆绑包(选中/_cassette),并且它没有向页面输出任何内容。对我们来说,该项目不是构建的,而是使用 CodeFile 的,我不确定这是否是问题的一部分。一般来说,No bundle with path 'xxx'无论我们尝试什么,我们都会不断收到异常。这是一个遗憾,因为我真的不介意将 CoffeeScript 融入解决方案。

是否有压缩/缩小 javascript 并可以使用 Sitecore 呈现 dotLess 文件的解决方案?

4

2 回答 2

3

在任何 Sitecore 客户端界面中工作时来自 Cassette 的空响应流是由rewriteHtml它实现的功能引起的。

默认情况下,Cassette 将缓冲和重写页面 HTML 输出。这允许部分视图在标签被渲染<link>后插入引用样式表的标签。<head>重写功能作为PostRequestHandlerExecute事件处理程序被调用。

您看到的空响应流是由于已重写的输出流没有被刷新。解决此问题的方法是在类上调用 Close 时刷新输出流Cassette.AspNet.PlaceholderReplacingResponseFilter,如下所示:

    void WriteUncompressedOutput()
    {
        var output = GetOutputWithPlaceholdersReplaced(bufferStream);
        var outputBytes = outputEncoding.GetBytes(output);
        if (outputBytes.Length > 0)
        {
            outputStream.Write(outputBytes, 0, outputBytes.Length);
            outputStream.Flush();
        }
    }

如果您不需要重写功能,现在可以使用解决方法。只需禁用 Cassette HTML 重写功能,无论是在web.config

<configuration>
    <configSections>
        ....
        <section name="cassette" type="Cassette.CassetteConfigurationSection, Cassette"/>
    </configSections>
    <cassette rewriteHtml="false"/>

或在代码中:

public class CassetteSettingsConfiguration : IConfiguration<CassetteSettings>
{
    public void Configure(CassetteSettings configurable)
    {
        configurable.IsHtmlRewritingEnabled = false;
    }
}

此信息包含在我关于将 Cassette 与 Sitecore 结合使用的博客文章中。

于 2013-04-13T15:35:48.567 回答
0

We ended up getting SquishIt to work rather easily and without much hassle besides getting the JavaScript files to play nicely together.

于 2012-06-20T12:38:42.487 回答