Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
560 views
in Technique[技术] by (71.8m points)

asp.net mvc - CssRewriteUrlTransform is not being called

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 my custom CssRewriteUrlTransform wrapper. And I found that my breakpoint is not being called.

This is what I have in my BundleConfig.cs

using System.Web.Optimization;

namespace Utilities.Web
{
    public class BundleConfig
    {
        private const string JQUERY_CDN_URL = "//code.jquery.com/jquery-1.10.1.min.js";

        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = true;
            BundleTable.EnableOptimizations = true;

            bundles.Add(new StyleBundle("~/css/coming-soon")
                .Include("~/Content/Site/coming-soon.css",
                    new CssRewriteUrlTransformWrapper()));

            bundles.Add(new ScriptBundle("~/js/coming-soon")
                .Include("~/Scripts/jquery.placeholder.js")
                .Include("~/Scripts/Site/coming-soon.js"));

            bundles.Add(new ScriptBundle("~/js/jquery", JQUERY_CDN_URL)
            {
                CdnFallbackExpression = "window.jQuery"
            }.Include("~/Scripts/jquery-{version}.js"));
        }
    }

    public class CssRewriteUrlTransformWrapper : IItemTransform
    {
        public string Process(string includedVirtualPath, string input)
        {
            return new CssRewriteUrlTransform().Process(includedVirtualPath, input);
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It appears the transform does not run if you have the minified version of the CSS. Remove the .min.css file and it should start working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...