LastBye
LastBye

Reputation: 1173

Bundling not work for me -MVC

RegisterBundles :

bundles.Add(new ScriptBundle("~/bundles/AllScripts").Include(
    "~/Scripts/jquery.x123.{version}.js",
    "~/Scripts/bootstrap.js",
    "~/Scripts/jqRect.js"));

In the Shared Layout file :

@Scripts.Render("~/bundles/AllScripts")

In Global.asax we have :

BundleConfig.RegisterBundles(BundleTable.Bundles);

The scripts didn't combined, also didn't get minified.

This is in release mode.

Is there anything missed?

Upvotes: 2

Views: 385

Answers (2)

Abbas Amiri
Abbas Amiri

Reputation: 3204

When you develop your project with Debug mode, it doesn't combined and minified. However, you can force it to do that by setting

BundleTable.EnableOptimizations = true; 

Upvotes: 1

Rune
Rune

Reputation: 8380

In your web.config you need to set the attribute debug="false" in the <compilation>-tag.

This means that you can use this flag to allow javascript debugging locally before deploying (debugging minified and bundled javascript is obviously next to impossible).

NOTE: The "Release mode" flag only affects the way the C# (or VB.NET) compiler compiles your classes and is not related to the debug attribute of the <compilation>-tag. Also note that the debug attribute controls whether ASP.NET MVC caches the location of views on disk and thus has a great performance impact: you should always have debug=false in a production environment.

Upvotes: 2

Related Questions