【问题标题】:Visual Studio 2013 does not update minified bootstrap.cssVisual Studio 2013 不更新缩小的 bootstrap.css
【发布时间】:2014-11-08 09:24:17
【问题描述】:

在我的 ASP .NET MVC 5.1 应用程序中 bootstrap.css 文件中的部分:

@media (min-width: 768px) {
  .dl-horizontal dt {
    float: left;
    width: 160px;
    overflow: hidden;
    clear: left;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dl-horizontal dd {
    margin-left: 180px;
  }

我将width: 160px; 更改为width: 260px; 并将margin-left: 180px; 更改为margin-left: 280px;

我保存、重新加载、后来重新启动了 Visual Studio。在我的 Chrome 网站中,我检查了加载的样式:

.dl-horizontal dt {
float: left;
width: 160px; //STILL 160px !
overflow: hidden;
clear: left;
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
}

所以我通过 Visual Studio 检查了bootstrap.min.css,发现我对bootstrap.css 所做的更改并未应用于bootstrap.min.css,因此我手动将它们应用于缩小文件,Chrome 正确加载了它们。

如何让VS2013更新这个压缩文件?


编辑:我必须说,在 VS2013(今天)之前,在 boostrap.css 进行更改后确实更新了 boostrap.min.css。只是在这些更改之后没有这样做。

using System.Web;
using System.Web.Optimization;

namespace WebApplication2 {
    public class BundleConfig {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles) {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));

            // Set EnableOptimizations to false for debugging. For more information,
            // visit http://go.microsoft.com/fwlink/?LinkId=301862
            BundleTable.EnableOptimizations = true;
        }
    }
}

【问题讨论】:

  • 您是否使用样式包来加载文件?
  • @StephenMuecke 我不确定。来自bootstrap.min.css 的样式被加载到站点中,只是这个文件在boostrap.css 更改后没有更新。您的意思是:@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap")@Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") 中的 _Layout.csthml
  • 检查您的BundleConfig.cs 文件中是否包含包含bootstrap.css(不是bootstrap.min.css)的样式包
  • @StephenMuecke 和`BundleConfig.RegisterBundles(BundleTable.Bundles);` 在Global.asax?
  • 看起来是正确的。您应该从项目中删除 bootstrap.min.css 并让捆绑程序为您完成工作。在调试模式下,它将在视图中包含boostrap.css。在发布模式下,它将包含一个缩小版本。 This gives a good explanation

标签: css asp.net-mvc twitter-bootstrap visual-studio-2013


【解决方案1】:

最小文件在重建后更新。强制重建以更新 min.css 文件。如果您删除 bootstrap.min.css 然后重新构建项目,我会很好奇。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多