gpt4 book ai didi

asp.net-mvc-4 - Asp.Net MVC Bundle 不使用现有的 .min.js

转载 作者:行者123 更新时间:2023-12-02 20:34:17 25 4
gpt4 key购买 nike

我正在使用 Asp.Net MVC 4 和内置的 bundle 支持。在 BundleConfig.cs 中,我在 RegisterBundles 方法中添加了默认的 jquery:

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

我的项目中还包含 jquery-1.8.0.jsjquery-1.8.0.min.js

调试时一切正常,但是当我设置 debug="false" 来测试 bundle 时,它似乎正在缩小默认的 jquery 文件,而不是使用已经存在的缩小版本。当我在项目中查看 jquery 的“min”版本时,它在顶部包含一个小注释,第一个方法定义是 function(a,b)。当我在浏览器中查看输出时,注释丢失,并且第一个方法定义不同。

还有其他人遇到过这个问题吗?如何让 bundle 机制使用现有的 .min 文件而不重新缩小?

最佳答案

这可以通过在 web.config 中将属性 usePreMinifiedFiles 设置为 true 来设置

<core enableTracing="false" ...>
<js defaultMinifier="EdwardsJsMinifier" usePreMinifiedFiles="true">

关于asp.net-mvc-4 - Asp.Net MVC Bundle 不使用现有的 .min.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12478306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com