小编典典

ASP.NET Bundles 如何禁用缩小

all

我的 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))

阅读 75

收藏
2022-07-04

共1个答案

小编典典

如果您debug="true"web.config
中使用并Scripts/Styles.Render用于引用页面中的捆绑包,则应该关闭捆绑和缩小。BundleTable.EnableOptimizations = false将始终关闭捆绑和缩小(不管调试真/假标志)。

您可能没有使用Scripts/Styles.Render助手吗?如果您通过直接渲染对捆绑包的引用,BundleTable.Bundles.ResolveBundleUrl()您将始终获得缩小/捆绑的内容。

2022-07-04