ASP.NET Bundles 如何禁用缩小 [英] ASP.NET Bundles how to disable minification

查看:24
本文介绍了ASP.NET Bundles 如何禁用缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 web.config(s) 中都有 debug="true",我只是不希望我的包被缩小,但我似乎没有做任何事情禁用它.我试过 enableoptimisations=false,这是我的代码:

I have debug="true" in both my web.config(s), and I just don't want my bundles minified, but nothing I do seems to disable it. I've tried enableoptimisations=false, here is my code:

//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 也将始终关闭捆绑和缩小(无论调试真/假标志如何).

If you have debug="true" in web.config and are using Scripts/Styles.Render to reference the bundles in your pages, that should turn off both bundling and minification. BundleTable.EnableOptimizations = false will always turn off both bundling and minification as well (irrespective of the debug true/false flag).

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

Are you perhaps not using the Scripts/Styles.Render helpers? If you are directly rendering references to the bundle via BundleTable.Bundles.ResolveBundleUrl() you will always get the minified/bundled content.

这篇关于ASP.NET Bundles 如何禁用缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆