4

.NET MVC bundler is always minifying my file! (release mode), even though I don't want it to. How can I avoid this? I need to use a pre-minified verison, because the .net minifier causes incorrect JS in this case.

I'm using:

https://raw.github.com/mbest/knockout-deferred-updates/master/knockout-deferred-updates.min.js

and my code is:

bundles.Add(new ScriptBundle("~/bundles/test")
 .Include("~/Scripts/Libraries/knockout-deferred-updates.js")
 .Include("~/Scripts/Libraries/knockout-deferred-updates.min.js"));

I've tried just having one .Include etc. but it still minifies the .min file!

williamsandonz
  • 15,864
  • 23
  • 100
  • 186
  • I believe you can use a `Bundle` instead of a `ScriptBundle`, but I'm actually surprised it doesn't automatically pick up your pre-minified file (*don't* include the `.min.js`, *just include the `.js`* (but keep both files in the same directory) and it should do the rest - I assume you have tried this?) – lc. Sep 27 '13 at 00:58
  • Yep I tried that........ – williamsandonz Sep 27 '13 at 01:04

2 Answers2

1

To prevent bundling and minifying while in release mode, you can add the following to BundleConfig.cs:

BundleTable.EnableOptimizations = false;

More info here

GvM
  • 1,735
  • 14
  • 15
  • I don't want to prevent it, I just want it to realize I've already minified the file. + I would never want to programatically do that anyway... – williamsandonz Sep 27 '13 at 01:45
  • 1
    Have you tried clearing the IgnoreList? Similar to this question: http://stackoverflow.com/questions/11980458/bundler-not-including-min-files – GvM Sep 27 '13 at 02:11
0

It might help you

  public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            bundles.Add(new ScriptBundle("~/bundles/customer").Include("~/Scripts/app/Services/vm.customer.js"));

            //If Enable Bundling
            BundleTable.EnableOptimizations = true;

            //If Disable Bundling
            BundleTable.EnableOptimizations = false;

        }
Anil Singh
  • 4,173
  • 4
  • 41
  • 47