Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net MVC Bundle not using existing .min.js

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?

like image 971
AdmSteck Avatar asked Sep 18 '12 13:09

AdmSteck


2 Answers

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

<core enableTracing="false" ...>
     <js defaultMinifier="EdwardsJsMinifier" usePreMinifiedFiles="true">
like image 115
Carlos Martinez T Avatar answered Dec 04 '22 10:12

Carlos Martinez T


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

like image 38
Todd Carter Avatar answered Dec 04 '22 10:12

Todd Carter