我试图替换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()
?