ASP .NET MVC 4ソリューションで使用するすべてのファイルを縮小したくないので、たとえば、BundleConfig.csにこれがあります。
bundles.Add(new StyleBundle("~/CSS/bootstrap").Include(
"~/Content/Bootstrap/body.css",
"~/Content/Bootstrap/bootstrap-responsive.css",
"~/Content/Bootstrap/bootstrap-mvc-validation.css",
"~/Content/Bootstrap/bootstrap-theme.css",
"~/Content/Bootstrap/bootstrap.css"
));
...
そしてそれを縮小するために、もちろん私は以下を使用します:
BundleTable.EnableOptimizations = true;
だからそれは素晴らしい働きをします。
しかし今、1つのバンドルを除くすべてのファイルを縮小するにはどうすればよいですか?一部のCSSクラスを削除するバンドルに問題があり、これを縮小したくありません。
どんな助けでも大歓迎です。
Transforms.Clear()を使用して縮小をスキップしますが、ファイルはバンドルされたままにします
//declare bundle
var bundle = new ScriptBundle("~/javascripts/ckEditor")
.Include("~/Scripts/ckeditor/ckeditor.js")
.Include("~/Scripts/ckeditor/config.js");
//skip transformation. Result is that files are only bundled, but not minified.
bundle.Transforms.Clear();
bundles.Add(bundle);
また、置換を防ぐために、ディレクトリから.min.jsファイルを削除する必要があります
同様の問題がありました。解決策は、ビューでミニファイを無効にしてから有効にすることです。例えば
@{
BundleTable.EnableOptimizations = false;
}
@Styles.Render("~/layout")
@RenderSection("CSS", false)
@{
BundleTable.EnableOptimizations = true;
}
問題の原因はわかりませんが、次のことを試みました。
縮小するのではなく、バンドルするだけです。動作しません。
bundles.Add(new Bundle("~/CSS/bootstrap").Include(
"~/Content/Bootstrap/body.css",
"~/Content/Bootstrap/bootstrap-responsive.css",
"~/Content/Bootstrap/bootstrap-mvc-validation.css",
"~/Content/Bootstrap/bootstrap-theme.css",
"~/Content/Bootstrap/bootstrap.css"
));
UIエラーをオーバーライドします。動作しますが、一時的なパッチです。
最後に、標準のCSS呼び出しを使用することにしました(そして、コードに理由を説明するコメントをいくつか入れます)。
<link rel="stylesheet" href="/Content/Bootstrap/body.css">
<link rel="stylesheet" href="/Content/Bootstrap/bootstrap-responsive.css">
<link rel="stylesheet" href="/Content/Bootstrap/bootstrap-mvc-validation.css">
<link rel="stylesheet" href="/Content/Bootstrap/bootstrap-theme.css">
<link rel="stylesheet" href="/Content/Bootstrap/bootstrap.css">
より良いアイデアがあれば、私たちに知らせてください! :)