CssRewriteUrlTransform未在非缩小的CSS上调用

时间:2015-09-17 18:53:03

标签: c# css asp.net-mvc bundling-and-minification web-optimization

我试图替换CSS文件中的文件路径。我尝试了示例from this answer

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        BundleTable.EnableOptimizations = true;

        IItemTransform cssRewrite = new CssRewriteUrlTransformWrapper();
        bundles.Add(new StyleBundle("~/bundles/css/Components")
            .Include("~/Content/Components/jquery-ui/jquery-ui.css", cssRewrite)
            .Include("~/Content/Components/jquery-ui/jquery-ui.structure.css", cssRewrite)
            .Include("~/Content/Components/jquery-ui/jquery-ui.theme.css", cssRewrite)
            .Include("~/Content/Components/bootstrap/css/bootstrap.min.css", cssRewrite)
            .Include("~/Content/Components/datatables/css/jquery.dataTables.min.css", cssRewrite)
        );
    }
}

public class CssRewriteUrlTransformWrapper : IItemTransform
{
    public string Process(string includedVirtualPath, string input)
    {
        return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input);
    }
}

由于某些原因,只有最后两个缩小的文件会触发Process()方法。当我使用他们的非缩小版本时,没有一个文件通过Process()。此行为与this solution完全相反。

如何为每个文件调用CssRewriteUrlTransformWrapper.Process()

0 个答案:

没有答案