不包含在@ Scripts.Render中时,脚本在调试模式下缩小

时间:2016-02-03 10:04:28

标签: asp.net asp.net-mvc debugging razor bundling-and-minification

在ASP.NET网站上,我们将BundleConfig.cs设置为在发布模式下缩小和连接脚本,但在调试模式下则不行。

在调试模式下,我有以下sestup 在web.config文件中。     

然后在Proj / App_Start / BundleConfig.cs

最后一行是

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

在调试模式下,脚本是未分析的,因此我们可以调试它们,但仅限于 在.cshtml页面中使用@ Scripts.Render。

但是,Web应用程序的某些特定部分是我们为小段功能动态加载脚本的。

使用jQuery.getScript我们称之为捆绑包的名称。

由于某种原因,这个脚本仍然缩小了所有调试器;断点是条纹。为什么是这样?

解决这个问题的唯一方法是执行以下操作。

#if DEBUG
// Iterate over each bundle ()   *not needed if compilation debug="true"
foreach (var bundle in bundles)
{
    // And strip out any transformations (minify)
    bundle.Transforms.Clear();
}
#endif  

这似乎是不必要的,我不知道为什么没有这个就行不通。

0 个答案:

没有答案
相关问题