【发布时间】:2015-05-11 15:59:26
【问题描述】:
我们正在使用功能标志(在 Web.Config 中设置)来切换某些尚未完成的功能在 UI 中的可见性。我还希望我的 MVC 包不包含相关的 JS 文件,因为它们只是在未启用该功能时客户端必须下载的无用文件。
到目前为止,我已经找到了 IgnoreList.Ignore,但我似乎无法让它工作。这基本上就是我正在做的事情:
public static void RegisterBundles(BundleCollection bundles)
{
if (!appConfiguration.FeatureXEnabled)
{
//Skip these files if the Feature X is not enabled!
//When this flag is removed, these lines can be deleted and the files will be included like normal
bundles.IgnoreList.Ignore("~/App/Organization/SomeCtrl.js", OptimizationMode.Always);
bundles.IgnoreList.Ignore("~/App/Filters/SomeFilter.js", OptimizationMode.Always);
}
var globalBundle = new ScriptBundle("~/bundles/app-global").Include(
"~/App/RootCtrl.js",
"~/App/Directives/*.js",
"~/App/Services/*.js",
"~/App/Application.js"
);
bundles.Add(globalBundle);
var appOrgBundle = new ScriptBundle("~/bundles/app-org");
appOrgBundle.Include(
"~/App/Filters/*.js",
"~/App/Organization/*.js"
);
bundles.Add(appOrgBundle);
}
使用上面的代码,忽略列表中的文件仍然被包含在内!我在这里做错了什么?
【问题讨论】:
标签: c# asp.net-mvc bundling-and-minification