ASP.NET Bundles如何禁用缩小
我在我的web.config(s)中都有debug="true"
,我只是不希望我的包被缩小,但我没有做任何事情似乎禁用它。 我试过enableoptimisations=false
,这里是我的代码:
//Javascript
bundles.Add(new ScriptBundle("~/bundles/MainJS")
.Include("~/Scripts/regular/lib/mvc/jquery.validate.unobtrusive.js*")
.Include("~/Scripts/regular/lib/mvc/jquery.validate*")
.Include("~/Scripts/regular/lib/bootstrap.js")
.IncludeDirectory("~/Scripts/regular/modules", "*.js", true)
.IncludeDirectory("~/Scripts/regular/pages", "*.js", true)
.IncludeDirectory("~/Scripts/regular/misc", "*.js", true));
//CSS
bundles.Add(new StyleBundle("~/bundles/MainCSS")
.Include("~/Content/css/regular/lib/bootstrap.css*")
.IncludeDirectory("~/Content/css/regular/modules", "*.css", true)
.IncludeDirectory("~/Content/css/regular/pages", "*.css", true))
如果在web.config中有debug="true"
,并且使用Scripts/Styles.Render
引用页面中的包,则应该关闭捆绑和缩小。 BundleTable.EnableOptimizations = false
将始终同时关闭捆绑和缩小(不论调试真假标志如何)。
你可能没有使用Scripts/Styles.Render
助手? 如果您通过BundleTable.Bundles.ResolveBundleUrl()
直接呈现对包的引用,则您将始终获取缩小/捆绑的内容。
条件编译指令是你的朋友:
#if DEBUG
var jsBundle = new Bundle("~/Scripts/js");
#else
var jsBundle = new ScriptBundle("~/Scripts/js");
#endif
要禁用捆绑和缩小,只需将此.aspx文件(即使在web.config中debug=true
,这将禁用优化)
vb.net:
System.Web.Optimization.BundleTable.EnableOptimizations = false
C#.NET
System.Web.Optimization.BundleTable.EnableOptimizations = false;
如果将EnableOptimizations = true
则即使在web.config中debug=true
,也会将其捆绑并缩小
上一篇: ASP.NET Bundles how to disable minification
下一篇: Talking from Android Adobe AIR application to local computer through USB