ASP.NET MVC: StyleBundle IncludeDirectory & CssRewriteUrlTransform

Viewed 2180

I have the same problem as many that my images are not resolved when I bundle my CSS-Stylesheets.

Now I found some SO-Answers that suggest using new CssRewriteUrlTransform() as second parameter for the "Include"-Method of a new StyleBundle-Object. This one for example

I'm using IncludeDirectory because I have a directory where I can add files without having them to register somewhere (and they are many files which I don't want to list). But IncludeDirectory doesn't have an override to pass a CssRewriteUrlTransform-Object:

Doesn't work: bundles.Add(new StyleBundle("~/bundles/css/directives").IncludeDirectory("~/app/directives", "*.css", true));

I also tried:

StyleBundle sb = new StyleBundle();
sb.Transforms.Add(new CssRewriteUrlTransform());

But Transforms are of Type IBundleTransform and I'm trying to pass an IItemTransform.

Any suggestions on how to do this?

2 Answers
Related