9

I am using Asp.Net MVC 4 and the built in bundling support. In BundleConfig.cs I have the default jquery addition in the RegisterBundles method:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

I also have both jquery-1.8.0.js and jquery-1.8.0.min.js included in my project.

Everything works fine when debugging, but when I set debug="false" to test the bundling, it appears that it is minifying the default jquery file instead of using the already existing minified version. When I view the 'min' version of jquery in my project, it includes a small comment at the top and the first method definition is function(a,b). When I view the output in my browser the comment is missing and the first method definition is different.

Has anyone else seen this problem? How can I get the bundling mechanism to use the existing .min file and not re-minify?

Hao Kung
  • 28,040
  • 6
  • 84
  • 93
AdmSteck
  • 1,753
  • 15
  • 25

3 Answers3

7

This can by set by setting the attribute usePreMinifiedFiles to true in the web.config

<core enableTracing="false" ...>
     <js defaultMinifier="EdwardsJsMinifier" usePreMinifiedFiles="true">
Carlos Martinez T
  • 6,458
  • 1
  • 34
  • 40
  • Thank you! In my version BundleTransformer.Configuration.xsd `usePreMinifiedFiles=true` is by default, but I need in `false` value. – dizel3d Nov 14 '14 at 06:29
  • Can you help me with my question http://stackoverflow.com/questions/26925521/how-to-prevent-usage-of-min-js-in-bundletransformer – dizel3d Nov 14 '14 at 08:28
2

Files with min in the name are excluded when adding files with wild cards, try renaming the file without the min in the name.

Todd Carter
  • 879
  • 7
  • 20
0

Is there a particular reason you don't want the file reminified? It should be safe. There's no way to currently selectively disable partial minification, basically all the files are bundled together first, and then the entire bundle is minified.

But when debug=false, it should be using the jquery-1.8.0.min.js file as opposed to the jquery-1.8.0.js file.

Hao Kung
  • 28,040
  • 6
  • 84
  • 93
  • First I was trying to understand how bundling works since the docs say the .min version will be used and it doesn't appear that way. Second, current builds of Opera have a bug that chokes on the dynamically minified version. [see here](http://ajaxmin.codeplex.com/workitem/17812) – AdmSteck Sep 18 '12 at 19:51
  • 2
    Since you are only bundling one file, and its already minified, you could just create a plain Bundle instead of a ScriptBundle, that will never minify your file. – Hao Kung Sep 18 '12 at 20:14