我正在使用 ASP.NET 捆绑机制:
BundleTable.Bundles.Add(new ScriptBundle("~/Scripts/Master-js").Include(
"~/Scripts/respond.min.js",
"~/Scripts/jquery.form.js",
"~/Scripts/jquery.MetaData.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/bootstrap.js",
"~/Scripts/jquery.viewport.js",
"~/Scripts/jquery.cookie.js"
));
如果构建正在发布,我希望发生这种情况。如果构建处于调试状态,我希望加载未缩小的单个文件,因此调试会很容易。
我能够做到这一点的唯一方法是在我看来写以下内容:
<% if(HttpContext.Current.IsDebuggingEnabled)
{
Response.Write("<script type='text/javascript' src='../../Scripts/respond.min.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/jquery.form.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/jquery.MetaData.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/jquery.validate.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/bootstrap.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/jquery.viewport.js'></script>");
Response.Write("<script type='text/javascript' src='../../Scripts/jquery.cookie.js'></script>");
}
else
{
Scripts.Render("~/Scripts/Master-js");
}
%>
如您所见,我在这里重复自己。有没有更好的办法?