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!

2
  • 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?) Commented Sep 27, 2013 at 0:58
  • Yep I tried that........ Commented Sep 27, 2013 at 1:04

2 Answers 2

1

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

BundleTable.EnableOptimizations = false; 

More info here

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

2 Comments

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...
Have you tried clearing the IgnoreList? Similar to this question: stackoverflow.com/questions/11980458/…
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; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.