CssRewriteUrlTransform is not being called

前端 未结 3 640
灰色年华
灰色年华 2020-12-09 09:02

I just created a new MVC 5 app on VS 2013 RTM. For some reason background image url in my CSS files were not being transformed.

So, to debug the issue, I created m

3条回答
  •  孤街浪徒
    2020-12-09 09:24

    I have the same problem. Сlass CssRewriteUrlTransform does not work as I need. I looked at the source code AspNetWebOptimization and found that when Bundle finds a file with ".min", it creates a new BundleFile without transforms from the original BundleFile. The best solution is to turn off the FileExtensionReplacement for these bundles:

    var bundle = new StyleBundle("~/bundles/css/font-awesome")
        .Include("~/Content/font-awesome.css", new CssRewriteUrlTransform());
    bundle.EnableFileExtensionReplacements = false;
    bundles.Add(bundle);
    

提交回复
热议问题