在 ASP.NET MVC 4 中的调试模式下启用捆绑和缩小 [英] Enable bundling and minification in debug mode in ASP.NET MVC 4

查看:27
本文介绍了在 ASP.NET MVC 4 中的调试模式下启用捆绑和缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不敢相信我找不到关于此的其他问题,但是:如何在调试模式下启用捆绑?我知道如何为发布模式启用它,但在调试模式下我找不到启用捆绑的方法.

I can't believe I cannot find other questions about this, but: how does one enable bundling in debug mode? I know how it is enabled for release mode, but in debug mode I cannot find a way to enable the bundling.

这是可能的还是我遗漏了什么?

Is this even possible or am I missing something?

推荐答案

您可以通过添加启用此

BundleTable.EnableOptimizations = true;

在您的 RegisterBundles 方法(App_Start 文件夹中的 BundleConfig 类)中.

in your RegisterBundles method (BundleConfig class in the App_Start folder).

检查 http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification 了解更多信息

您也可以更改您的 web.config:

You could also change your web.config:

<system.web>
    <compilation debug="false" />
</system.web>

但这会完全禁用调试模式,所以我推荐第一个选项.

But this would disable debug mode entirely so I would recommend the first option.

最后,为了两全其美,请像这样使用 #if 编译器指令:

Finally, to get the best of both worlds, use the #if compiler directive like this:

#if DEBUG
            BundleTable.EnableOptimizations = false;
#else
            BundleTable.EnableOptimizations = true;
#endif

这篇关于在 ASP.NET MVC 4 中的调试模式下启用捆绑和缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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