本文介绍了CssRewriteUrlTransform不带的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bundles.Add(new StyleBundle("~/a/b/c")
    .Include("~/Content/font-awesome.css", new CssRewriteUrlTransform()));

我有这个捆绑包.字体超赞的CSS具有定义为url('../fonts/fontawesome-webfont.eot?v=4.0.3')的url,该URL在css位于"~/Content/font-awesome.css"下但现在位于〜/a/b"

I have this bundling. The font-awesome css has a url defined as url('../fonts/fontawesome-webfont.eot?v=4.0.3') which is valid when the css is located under "~/Content/font-awesome.css" but now its located under "~/a/b"

但是CssRewriteUrlTransform不能插入并将路径重写为url('../../fonts/fontawesome-webfont.eot?v=4.0.3')

But CssRewriteUrlTransform does not kick in and rewrite path to url('../../fonts/fontawesome-webfont.eot?v=4.0.3')

更新:如果我删除了.min文件,该文件CssRewriteUrlTransform开始起作用,是否存在网页优化错误?

Update: If I remove the .min file it CssRewriteUrlTransformstarts to work, bug in web optimization?

https://aspnetoptimization.codeplex.com/workitem/166

推荐答案

我遇到了同样的问题.

您需要设置相对于文件文件夹的捆绑包网址.

You need to set the Bundle url relative to the folder of your file.

bundles.Add(new StyleBundle("~/Content/fontawesomebundle")
    .Include("~/Content/font-awesome.css", new CssRewriteUrlTransform()));

更新:看来CssRewriteUrlTransform不适用于min文件.在包含文件中使用.min文件或删除min文件.

Update:It appears that CssRewriteUrlTransform doesn't work for min file.Either use .min file in the include or remove the min file.

这篇关于CssRewriteUrlTransform不带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:55