捆绑和缩小,当捆绑时,我的一个脚本在加载时死掉了。如果没有,那就完全没问题了
Bundling and Minification, when bundled one of my script dies at load time.. When not, it's perfectly fine
我在捆绑和缩小方面遇到了麻烦..
这是一个设置,如果我打开了 M&B,它会被缩小并添加,我的订单工作正常..
当 M&B 关闭时,一切正常。
当 M&B 打开时,一切都被缩小并且看起来像是按正确的顺序创建的。但是我的一个脚本在加载时崩溃了......
但仅当捆绑...或当 Min&Bundled...
这是有问题的
<script type="text/javascript" src="@Url.JScript("jquery-ui-1.8.9.custom.min.js")" ></script>
<script type="text/javascript" src="@Url.JScript("jquery.validate.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.unobtrusive-ajax.min.js")" ></script>
<script type="text/javascript" src="@Url.JScript("grid.locale-en.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.jqGrid.js")"></script>
<script type="text/javascript" src="@Url.JScript("grid.addons.js")"></script> <<<----- this one dies at load time when minified!!!
当它缩小并 grid.addon.js 并加载时,它给出以下错误。
对象不支持此 属性 或方法。
这是有问题的非缩小位
$.jgrid.extend({
// This is the ols search Filter method used in navigator.
searchGrid : function (p) {
我得到的错误是 $.jgrid 没有扩展方法。当我调试并查看加载的对象时,确实没有 .extend 方法。
但是当 M&B 关闭时,一切正常。
这是我在 Global.asax.cs
中的 m&B 代码
public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
//
BundleTable.Bundles.IgnoreList.Clear(); // apparently, IgnoreList included .min.js in debug
BundleTable.Bundles.IgnoreList.Ignore(".intellisense.js", OptimizationMode.Always);
BundleTable.Bundles.IgnoreList.Ignore("-vsdoc.js", OptimizationMode.Always);
BundleTable.Bundles.IgnoreList.Ignore(".debug.js", OptimizationMode.Always);
var styles = new StyleBundle("~/Bundling/RzrRootBundledcss").Include(
"~/Assets/CSS/Jcdc.css",
"~/Assets/CSS/jqueryslidemenu.css",
"~/Assets/CSS/ViewDetails.css",
"~/Assets/CSS/Site.css",
"~/Assets/CSS/UserInformation.css",
"~/Assets/CSS/ui.jqgrid.blue.css",
"~/Assets/CSS/blue/jquery-ui-1.8.9.custom.css",
"~/Assets/CSS/cupertino/jquery-ui-1.8.5.custom.css",
"~/Assets/CSS/Blueprint.css",
"~/Assets/CSS/BlueSite.css",
"~/Assets/CSS/timepick.css",
"~/Assets/CSS/ui.spinner.css"
).ForceOrdered();
INetLog log = ObjectFactory.GetInstance<INetLog>();
log.Debug("done mini and budle css");
//ScriptBundle
Bundle js = new Bundle("~/Bundling/RzrRootBundledjs");
//js.Orderer = new AsIsBundleOrderer();
BundleFileSetOrdering bundleFileSetOrdering1 = new BundleFileSetOrdering("RzrRootBundledjs");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-1.4.2.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.locale-en.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.jqGrid.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.addons.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/json2.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JcdcInputValidation.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.hoverIntent.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jqueryslidemenu.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.corner.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.ezpz_tooltip.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/../JQGrid/JQGridDefaults.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCEdit.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCAjaxNew.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.alphanumeric.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/additional-methods.js?version=1.0");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.livequery.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.blockUI.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.timePicker.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.debug.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.mapping-latest.debug.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.validation.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout-deferred-updates.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/ui.spinner.js");
bundleFileSetOrdering1.Files.Add("~/Content/ASPNetSpellInclude/include.js");
bundles.FileSetOrderList.Clear();
BundleTable.Bundles.FileSetOrderList.Insert( 0, bundleFileSetOrdering1 );
//ScriptBundle js = new ScriptBundle("~/Bundling/RzrRootBundledjs");
//js.Orderer = new AsIsBundleOrderer();
js.Include("~/Assets/JavaScript/jquery-1.4.2.min.js")
.Include("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js")
.Include("~/Assets/JavaScript/jquery.validate.js")
.Include("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js" )
.Include("~/Assets/JavaScript/grid.locale-en.js")
.Include( "~/Assets/JavaScript/jquery.jqGrid.js")
.Include( "~/Assets/JavaScript/grid.addons.js")
.Include("~/Assets/JavaScript/json2.js")
.Include("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js" )
.Include("~/Assets/JavaScript/JcdcInputValidation.js" )
.Include("~/Assets/JavaScript/jquery.hoverIntent.js" )
.Include("~/Assets/JavaScript/jqueryslidemenu.js" )
.Include("~/Assets/JavaScript/jquery.corner.js")
.Include("~/Assets/JavaScript/jquery.ezpz_tooltip.js" )
.Include("~/Assets/JQGrid/JQGridDefaults.js")
.Include("~/Assets/JavaScript/JCDCEdit.js")
.Include("~/Assets/JavaScript/JCDCAjaxNew.js")
.Include("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js" )
.Include("~/Assets/JavaScript/jquery.alphanumeric.js")
.Include("~/Assets/JavaScript/additional-methods.js?version=1.0")
.Include("~/Assets/JavaScript/jquery.livequery.js")
.Include("~/Assets/JavaScript/jquery.blockUI.js")
.Include("~/Assets/JavaScript/jquery.timePicker.js")
.Include("~/Assets/JavaScript/knockout.debug.js")
.Include("~/Assets/JavaScript/knockout.mapping-latest.debug.js")
.Include("~/Assets/JavaScript/knockout.validation.js")
.Include("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js")
.Include("~/Assets/JavaScript/knockout-deferred-updates.js")
.Include("~/Assets/JavaScript/ui.spinner.js")
.Include("~/Content/ASPNetSpellInclude/include.js");
log.Debug("done minify and bundle script");
bundles.Add(styles);
bundles.Add(js);
//BundleTable.EnableOptimizations = true;
log.Debug("done generating bundles");
}
}
这是我从布局页面注入的。
@Styles.Render("~/Bundling/RzrRootBundledcss");
@Scripts.Render("~/Bundling/RzrRootBundledjs");
我查看了 Jquery.JQgrid.js,它在自己的代码中使用了 .Extend 方法。现在我真的很困惑。
所以我有 2 个问题...
- 有谁知道我显然没有完全理解的是什么?,或者可以给我一些提示,告诉我该去哪里看?我开始怀疑缩小正在重命名扩展方法...不知道如何解决这个问题。
- 如何强制调试器在加载时中断
如果您能提供任何帮助或提示,我们将不胜感激...
我真的不喜欢这个答案,但我必须做的是让它工作,将有问题的 js 文件从包中取出(以及所有依赖它的文件)并正常注入它们。
测试它也很痛苦...基本上是应用程序的完全回归,但它确实有效。
我在捆绑和缩小方面遇到了麻烦..
这是一个设置,如果我打开了 M&B,它会被缩小并添加,我的订单工作正常.. 当 M&B 关闭时,一切正常。 当 M&B 打开时,一切都被缩小并且看起来像是按正确的顺序创建的。但是我的一个脚本在加载时崩溃了...... 但仅当捆绑...或当 Min&Bundled...
这是有问题的
<script type="text/javascript" src="@Url.JScript("jquery-ui-1.8.9.custom.min.js")" ></script>
<script type="text/javascript" src="@Url.JScript("jquery.validate.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.unobtrusive-ajax.min.js")" ></script>
<script type="text/javascript" src="@Url.JScript("grid.locale-en.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.jqGrid.js")"></script>
<script type="text/javascript" src="@Url.JScript("grid.addons.js")"></script> <<<----- this one dies at load time when minified!!!
当它缩小并 grid.addon.js 并加载时,它给出以下错误。 对象不支持此 属性 或方法。
这是有问题的非缩小位
$.jgrid.extend({
// This is the ols search Filter method used in navigator.
searchGrid : function (p) {
我得到的错误是 $.jgrid 没有扩展方法。当我调试并查看加载的对象时,确实没有 .extend 方法。
但是当 M&B 关闭时,一切正常。
这是我在 Global.asax.cs
中的 m&B 代码public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
//
BundleTable.Bundles.IgnoreList.Clear(); // apparently, IgnoreList included .min.js in debug
BundleTable.Bundles.IgnoreList.Ignore(".intellisense.js", OptimizationMode.Always);
BundleTable.Bundles.IgnoreList.Ignore("-vsdoc.js", OptimizationMode.Always);
BundleTable.Bundles.IgnoreList.Ignore(".debug.js", OptimizationMode.Always);
var styles = new StyleBundle("~/Bundling/RzrRootBundledcss").Include(
"~/Assets/CSS/Jcdc.css",
"~/Assets/CSS/jqueryslidemenu.css",
"~/Assets/CSS/ViewDetails.css",
"~/Assets/CSS/Site.css",
"~/Assets/CSS/UserInformation.css",
"~/Assets/CSS/ui.jqgrid.blue.css",
"~/Assets/CSS/blue/jquery-ui-1.8.9.custom.css",
"~/Assets/CSS/cupertino/jquery-ui-1.8.5.custom.css",
"~/Assets/CSS/Blueprint.css",
"~/Assets/CSS/BlueSite.css",
"~/Assets/CSS/timepick.css",
"~/Assets/CSS/ui.spinner.css"
).ForceOrdered();
INetLog log = ObjectFactory.GetInstance<INetLog>();
log.Debug("done mini and budle css");
//ScriptBundle
Bundle js = new Bundle("~/Bundling/RzrRootBundledjs");
//js.Orderer = new AsIsBundleOrderer();
BundleFileSetOrdering bundleFileSetOrdering1 = new BundleFileSetOrdering("RzrRootBundledjs");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-1.4.2.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.locale-en.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.jqGrid.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.addons.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/json2.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JcdcInputValidation.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.hoverIntent.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jqueryslidemenu.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.corner.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.ezpz_tooltip.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/../JQGrid/JQGridDefaults.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCEdit.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCAjaxNew.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.alphanumeric.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/additional-methods.js?version=1.0");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.livequery.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.blockUI.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.timePicker.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.debug.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.mapping-latest.debug.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.validation.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout-deferred-updates.js");
bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/ui.spinner.js");
bundleFileSetOrdering1.Files.Add("~/Content/ASPNetSpellInclude/include.js");
bundles.FileSetOrderList.Clear();
BundleTable.Bundles.FileSetOrderList.Insert( 0, bundleFileSetOrdering1 );
//ScriptBundle js = new ScriptBundle("~/Bundling/RzrRootBundledjs");
//js.Orderer = new AsIsBundleOrderer();
js.Include("~/Assets/JavaScript/jquery-1.4.2.min.js")
.Include("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js")
.Include("~/Assets/JavaScript/jquery.validate.js")
.Include("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js" )
.Include("~/Assets/JavaScript/grid.locale-en.js")
.Include( "~/Assets/JavaScript/jquery.jqGrid.js")
.Include( "~/Assets/JavaScript/grid.addons.js")
.Include("~/Assets/JavaScript/json2.js")
.Include("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js" )
.Include("~/Assets/JavaScript/JcdcInputValidation.js" )
.Include("~/Assets/JavaScript/jquery.hoverIntent.js" )
.Include("~/Assets/JavaScript/jqueryslidemenu.js" )
.Include("~/Assets/JavaScript/jquery.corner.js")
.Include("~/Assets/JavaScript/jquery.ezpz_tooltip.js" )
.Include("~/Assets/JQGrid/JQGridDefaults.js")
.Include("~/Assets/JavaScript/JCDCEdit.js")
.Include("~/Assets/JavaScript/JCDCAjaxNew.js")
.Include("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js" )
.Include("~/Assets/JavaScript/jquery.alphanumeric.js")
.Include("~/Assets/JavaScript/additional-methods.js?version=1.0")
.Include("~/Assets/JavaScript/jquery.livequery.js")
.Include("~/Assets/JavaScript/jquery.blockUI.js")
.Include("~/Assets/JavaScript/jquery.timePicker.js")
.Include("~/Assets/JavaScript/knockout.debug.js")
.Include("~/Assets/JavaScript/knockout.mapping-latest.debug.js")
.Include("~/Assets/JavaScript/knockout.validation.js")
.Include("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js")
.Include("~/Assets/JavaScript/knockout-deferred-updates.js")
.Include("~/Assets/JavaScript/ui.spinner.js")
.Include("~/Content/ASPNetSpellInclude/include.js");
log.Debug("done minify and bundle script");
bundles.Add(styles);
bundles.Add(js);
//BundleTable.EnableOptimizations = true;
log.Debug("done generating bundles");
}
}
这是我从布局页面注入的。
@Styles.Render("~/Bundling/RzrRootBundledcss");
@Scripts.Render("~/Bundling/RzrRootBundledjs");
我查看了 Jquery.JQgrid.js,它在自己的代码中使用了 .Extend 方法。现在我真的很困惑。
所以我有 2 个问题...
- 有谁知道我显然没有完全理解的是什么?,或者可以给我一些提示,告诉我该去哪里看?我开始怀疑缩小正在重命名扩展方法...不知道如何解决这个问题。
- 如何强制调试器在加载时中断
如果您能提供任何帮助或提示,我们将不胜感激...
我真的不喜欢这个答案,但我必须做的是让它工作,将有问题的 js 文件从包中取出(以及所有依赖它的文件)并正常注入它们。
测试它也很痛苦...基本上是应用程序的完全回归,但它确实有效。