2

I'm trying to replace file paths inside CSS files. I tried the example 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);
    }
}

For some reason only the last two minified files trigger the Process() method. When I use their non-minified versions, then none of the files go through Process(). This behavior is the exact opposite of this solution.

How do I get CssRewriteUrlTransformWrapper.Process() called for every file?

Community
  • 1
  • 1
Marcos Dimitrio
  • 6,651
  • 5
  • 38
  • 62

0 Answers0