0

MVC4 C# web site, running in debug mode, the code in "BundleConfig" file is has:

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
                "~/Scripts/jquery-1.8.2.min.js", 
                "~/Scripts/jquery.simplemodal.js", 
                "~/Scripts/jquery-ui-1.9.2.custom.min.js", 
                "~/Scripts/jquery.validate.js", 
                "~/Scripts/jquery.validate.unobtrusive.min.js", 
                "~/Scripts/site.js", 
                "~/Scripts/jquery.watermark.js", 
                "~/Scripts/jquery.signalR-0.5.3.min.js" ,
                "~/Scripts/jquery.dataTables.js"

In web.config, debug="true"

I open firebug and see that in the "net -> js" tab section, only calls to not minify js is being made. All minify js files are not being requested from the client.

In my layout my code is:

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

The problem started after I installed the "Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0" package from nuget... when I run the web site in release mode all working good. I don't have the not minify js files and I want to continue working in Debug mode. How can I fix it ? Why no request to minify js from client occurs?

1 Answer 1

1

When using Bundling and Minification in debug mode, bundling/minification is disabled.

You can override this and force bundling and minification by adding BundleTable.EnableOptimizations = true; to your RegisterBundles.

public static void RegisterBundles(BundleCollection bundles)
{
    //your bundle code
    BundleTable.EnableOptimizations = true;
}

UPDATE: Seeing your comment it seems I misunderstood your question.

When you are in debug mode and BundleTable.EnableOptimizations = false, the .min version of files are NOT used. Instead, the full debug version of the files will be used. So your scripts folder should have BOTH versions of the files: like

jquery-1.9.1.min.js 
jquery-1.9.1.js

In debug mode, jquery-1.9.1.js will be used. In release mode, jquery-1.9.1.min.js will be used.

If you only have one version of the file, then just remove the ".min" from the file name.

Sign up to request clarification or add additional context in comments.

3 Comments

this will cause all files to be minified ... I want to be able to see other files in firebug as well.
but I have some files only in "min" version. I want them to be served in debug mode as well. it was working until I downloaded display modes package from nuget to make my site work on mobile.
@HaddarMacdasi I updated my answer. Hopefully this clarifies things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.