在开发中,对于未组合和未缩小的文件,捆绑按预期工作,但在部署带有 web.config 设置的站点后启用捆绑
<compilation debug="false" targetFramework="4.5" />
get a request to a bundle 的结果可能在顶部包含类似于以下的评论
/* Minification failed. Returning unminified contents.
.. errors like JS1002 or JSxxxx errors
在其他情况下,缩小不会抛出任何错误,但某些 javascript 无法运行或在执行期间出错。
在其他情况下工作的 javascript 中的哪些语法可能会在捆绑后导致此行为?
最佳答案
可能导致这种情况的一种情况是单行注释//作为 javascript 文件的最后一行。这将导致附加的下一个文件至少第一行也被注释掉
例如,如果你有一个包
bundles.Add(New ScriptBundle("~/bundles/test").Include(
"~/Scripts/adder.js",
"~/Scripts/printer.js"))
加法器
function adder(a, b) {
return a + b;
}
//this is the adder.js
打印机.js
printer = true;
if (printer) {
alert("It works");
document.getElementById("itWorked").textContent = "It worked";
}
关于javascript - ASP.NET 包在部署时不起作用(调试 ="false"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14223942/