MVC4 Internet Application template bundle enabled by default?
Pergunta
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.
Solução
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.
Outras dicas
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.