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

查看:306
本文介绍了在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).

检查<一href=\"http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification\">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.

最后,得到两全其美,这样使用#如果编译器指令:

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天全站免登陆