0

I am using Mvc 4 project from Internet Application template. Why bundle feature does not enabled by default or am I missing something?

There is no such methods like this in Mvc4 as mentioned by other post:

BundleTable.Bundles.RegisterTemplateBundles();
BundleTable.Bundles.EnableDefaultBundles();

Update: This how to enable bundle in debug mode

BundleTable.EnableOptimizations = true;

after registering bundles.

CallMeLaNN
  • 8,328
  • 7
  • 59
  • 74

2 Answers2

3

Bundles are registered and enabled by default. When you run in Release mode (debug="false") in your web.config the @Script.Render helper will concatenate and minify the resources into a single file. If you run in Debug mode then each script will be rendered separately.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Yes, my bad I forget about debug mode in web.config. but I want to force to turn it on for testing in debug mode. I found that adding `BundleTable.EnableOptimizations = true` after registering the bundle will force it to be enabled. – CallMeLaNN Oct 20 '12 at 08:39
1

I run into a similiar issue and my solution is this:

public class bundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        // bundle as usual


#if(!DEBUG)
        BundleTable.EnableOptimizations = true;
#endif
    }
}

This way, when I launch it in Release mode, it does minification and bundling but if I launch it in Debug mode, it doesn't.

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137