我将捆绑添加到我的 MVC 3 应用程序中。我下载了 Microsoft.Web.Optiminization.1.1.3 的 nugetpackage 我将它添加到我的 Globals.asax
public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
//CSS
var styles = new StyleBundle("~/Bundling/bundledcss").Include(
"~/Content/site.css",
"~/Content/ASPNetSpellInclude/themes/bright/*.css",
"~/Content/ASPNetSpellInclude/themes/buttons/*.css",
"~/Content/ASPNetSpellInclude/themes/classic/*.css",
"~/Assets/CSS/*.css",
"~/Assets/CSS/blue/*.css",
"~/Assets/CSS/cupertino/*.css",
"~/Assets/JQGrid/css/cupertino/*.css"
);
INetLog log = ObjectFactory.GetInstance<INetLog>();
log.Debug("done mini and budle css");
//JS
var js = new ScriptBundle("~/Bundling/bundledjs").Include(
"~/Scripts/*.js",
"~/Content/*.js",
"~/Content/ASPNetSpellInclude/*.js",
"~/Content/ASPNetSpellInclude/core/*.js",
"~/Content/ASPNetSpellInclude/debugging-test-scripts/*.js",
"~/Content/ASPNetSpellInclude/translations/*.js",
"~/Content/ASPNetSpellInclude/*.js",
"~/Assets/JavaScript/*.js",
"~/Assets/JavaScript/i18n/*.js",
"~/Assets/JQGrid/js/*.js",
"~/Assets/JQGrid/js/i18n/*.js"
);
log.Debug("done minify and bundle script");
bundles.Add(styles);
bundles.Add(js);
BundleTable.EnableOptimizations = true;
log.Debug("done generating bundles");
}
从 Application_Start 调用
protected void Application_Start
{
<snip>
RegisterBundles(BundleTable.Bundles);
}
在我的根布局页面上,我有这些
<link rel="stylesheet" type="text/css" href="@Styles.Url("~/Assets/CSS/Jcdc.css")" />
<script type="text/javascript" src="@Scripts.Url( "~/Assets/JavaScript/jquery-1.4.2.min.js")"></script>
我的 web.config 有 debug = false
<compilation debug="false" targetFramework="4.0">
但是当我在页面上运行并查看源代码时......我仍然看到这个。
<link rel="stylesheet" type="text/css" href="/CIS3G/Assets/CSS/Jcdc.css" />
...
<script type="text/javascript" src="/CIS3G/Assets/JavaScript/jquery-1.4.2.min.js"></script>
这意味着缩小和捆绑不起作用,对吗?
本文
表明我应该期待
所以它显然不起作用......
有人看到我错过了什么,我读过的所有内容都告诉我它应该可以工作吗?