5

I'm not clear what I'm missing here. As far as I can tell I've followed the instruction here. But my css bundle is still not getting minified.

Here's my RegisterBundles code:

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

    bundles.Add(new ScriptBundle("~/bundles/otherjquery").Include(
            "~/App_Themes/Travel2/Script/jquery-ui.min.js",
            "~/Scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.unobtrusive-ajax.js"));

   Bundle availabiltyResult = new StyleBundle("~/bundles/css/availabiltyResult").Include(
                "~/CSS/Travel2/Air.css",
                "~/CSS/Travel2/Air/AvailabiltyResults.css"
                );
    availabiltyResult.Transforms.Add(new CssMinify());
    bundles.Add(availabiltyResult);
}

I've disabled debugging in my web.config by removing the <compilation debug="true">. I can see the js getting bundled and minified:

enter image description here

but the css is getting bundled but not minified:

enter image description here

What am I missing here?

Liam
  • 27,717
  • 28
  • 128
  • 190

2 Answers2

1

The problem was that the file was getting minified but that FireBug was re-parsing the code so it looked like it wasn't. Looking at it using Fiddler I can see that the css is (in fact) getting minified:

enter image description here

Kudos to @Kimi for the spotting it.

Liam
  • 27,717
  • 28
  • 128
  • 190
-1

You have to build your code as Release.

baHI
  • 1,510
  • 15
  • 20
  • No I don't. The web.config does this not the debug variable. – Liam Feb 06 '15 at 16:24
  • It has nothing to do with the config. The VS does the minifying at building the solution - therefore you have to set Release build and start/rebuild the project.Next time read your answer, before you shoot from hip! Just think about: while you do debugging, minifying would be unconvenient, so that's why minifying occours only when you do a Release build. At least this works for JS. – baHI Feb 06 '15 at 16:33
  • No, that's wrong. I am running it right now in DEBUG and the minification is happening. The `` actually turns it on or off. You sure you don't have you release config set to remove this setting from the web.config? – Liam Feb 06 '15 at 16:35
  • 2
    Actually, by default the web.config has `compilation debug="true"` turned off. Which directly impacts the minification process. So as long as that is enabled, it doesn't need to be in *release*. Rick Anderson has a really stellar article about the whole process here. http://www.asp.net/mvc/overview/performance/bundling-and-minification – Greg Feb 06 '15 at 16:36