21

MVC4 アプリをデバッグ モードで実行すると (css/script が縮小されないため)、正常に動作します。デバッグ (css/scripts 縮小) なしで実行するとすぐに、Twitter Bootstrap アイコンが表示されません。ここの別のスレッドはbundles.IgnoreList.Clear()の使用を提案しました。しかし、それは私にはうまくいかないようです。私の BundleConfig.RegisterBundles(...) は次のようになります。

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.IgnoreList.Clear();

    // Some JavaScript bundles only
    // ...

    bundles.Add(new StyleBundle("~/bundles/maincss").Include(
        "~/Content/bootstrap.css",
        "~/Content/bootstrap-responsive.css",
       "~/Content/my.css"));
    }
}

すべてのパッケージは Nuget を使用してインストールされました (デバッグ モードでは問題なく動作します)。My Content フォルダーには、両方の bootstrap...css ファイルの縮小版も含まれていますが、my.css の縮小版は含まれていません。グリフ アイコンは images サブフォルダーにあります。

私の _Layout.cshtml は次のようになります。

<head>
    ...
    @Styles.Render("~/bundles/maincss")
</head>

「非デバッグ」モードとは、Web.config ファイルで debug="false" オプションを設定することを意味します。

<compilation debug="false" targetFramework="4.5" />

Twitterのブートストラップアイコンが「非デバッグ」モードで表示されない理由を知っている人はいますか?

ありがとうロブ

4

2 に答える 2

10

Bootstrap 3.0を使用して同じことに遭遇しました。@ brad-christie の回答は、NuGet を使用して Microsoft ASP.Net Web 最適化フレームワーク 1.1.1 にアップグレードするまで、私の問題を解決しました。これにより、CssRewriteUrlTransform修正が機能しなくなったようです。への参照を削除し、次のものだけを含むCssRewriteUrlTransformスタイル シートbootstrap-bundle-font-fix.cssを作成することで問題を解決しました。

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../../Content/fonts/glyphicons-halflings-regular.eot');
  src: url('../../Content/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), 
       url('../../Content/fonts/glyphicons-halflings-regular.woff') format('woff'),
       url('../../Content/fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
       url('../../Content/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}

そして、それをブートストラップ css バンドルに含めます。

bundles.Add(new StyleBundle("~/bundles/Content/bootstrap")
    .Include("~/Content/bootstrap/bootstrap.css")
    .Include("~/Content/bootstrap/bootstrap-theme.css")
    .Include("~/Content/bootstrap-bundle-font-fix.css")
    .Include("~/Content/sticky-footer-navbar.css"));
于 2013-10-11T13:44:05.667 に答える