Asp.Net bundling not using the .min files

五迷三道 提交于 2020-01-23 06:58:05

问题


According to documentation in release mode the bundler should use the .min.js file if it exists. I am adding angular the following way:

bundles.Add(new ScriptBundle(Bundles.Scripts).Include(
                        "~/Content/Scripts/angular.js"));

I have angular.js and angular.min.js in the same folder. So according to what I understand the bundler should just use the angular.min.js and do not do anything itself. But when I check the result in the http response, it's different. It's also minified, but all the names are different:

What I get in the browser:

(function(n,t,i){"use strict";function v(n)

Angular.min.js

(function(P,X,u){'use strict';function M(b)

Can someone explain why this is happening? Does the bundler just ignore the .min file or it minifies again .min.js?

P.S. I have tried to delete the angular.js file and I get an empty result after that, so it seems the bundler does not care at all that angular.min.js exist.


回答1:


It seems that in case of a ScriptBundle the library does not do what it should and tries to minify any file. I changed it to just Bundle and that seems to make the trick and load the preminified versions.

Found the answer here: Style bundling for MVC4 not using min files




回答2:


Please have both normal and minified versions of a script in your project under the same folder like

script.js
script.min.js

You add only script.js to a bundle in your code. As a result the script.js included in DEBUG mode and script.min.js in RELEASE mode.

The Microsoft MVC4 Platform Considers that you have at least both minified version & unminified version for each Script or Style Bundle(another files like Debug and vsdoc are available too).



来源:https://stackoverflow.com/questions/29005594/asp-net-bundling-not-using-the-min-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!