asp.net - 缩小失败。返回未缩小的内容

标签 asp.net asp.net-mvc bundling-and-minification

我已经使用 MVC 5 创建了我的第一个网站,它在我的本地机器上运行良好,但是当我将它发布到服务器时,一些 CSS 没有正确缩小。

    /* Minification failed. Returning unminified contents.
    (80,1): run-time error CSS1019: Unexpected token, found '@import'
    (80,9): run-time error CSS1019: Unexpected token, found 'url('../Content/dark-skin/skin.css')'
    (671,16): run-time error CSS1062: Expected semicolon or closing curly-brace, found ':'
    (1288,16): run-time error CSS1062: Expected semicolon or closing curly-brace, found ':'
    (1680,1): run-time error CSS1019: Unexpected token, found '@keyframes'
    (1682,5): run-time error CSS1062: Expected semicolon or closing curly-brace, found '50%'
    (1685,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes'
    (1687,5): run-time error CSS1062: Expected semicolon or closing curly-brace, found '50%'
     */
    /* NUGET: BEGIN LICENSE TEXT
     *
     * Microsoft grants you the right to use these script files for the sole
     * purpose of either: (i) interacting through your browser with the Microsoft
     * website or online service, subject to the applicable licensing or use
     * terms; or (ii) using the files as included with a Microsoft product subject
     * to that product's license terms. Microsoft reserves all other rights to the
     * files not expressly granted by Microsoft, whether by implication, estoppel
     * or otherwise. The notices and licenses below are for informational purposes only.
     *
     * NUGET: END LICENSE TEXT */
    /*!
     * Bootstrap v3.0.0
     *
     * Copyright 2013 Twitter, Inc
     * Licensed under the Apache License v2.0
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Designed and built with all the love in the world by @mdo and @fat.
     *//*! normalize.css v2.1.0 | MIT License | git.io/normalize */

在尝试更正一些错误并再次发布后,错误看起来相同。

最奇怪的部分是 bootstrap.css为了网站的目的,我稍微修改了它。当我发布它时,更改不在包文件中。是否有可能从 Bootstrap 服务器而不是我的项目加载 bootstrap ?

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

我还尝试使用 Web 应用程序自己进行缩小,但我的更改不可见,并且文件似乎没有缩小。

任何帮助表示赞赏。

最佳答案

我通过做两件事解决了捆绑 bootstrap.css 的问题:

  • 包括 bootstrap.css 第一 在捆绑。问题中的代码示例已经这样做了,但我没有。
  • 添加 官方缩小版 (bootstrap.min.css) 到与未缩小版本相同目录中的项目。这会提示捆绑器使用现有的缩小文件,而不是尝试(但失败)缩小 bootstrap.css 本身。请参阅下面屏幕截图中的绿色箭头。

  • 请注意,如果您使用特定主题,请将 bootstrap.css 和 bootstrap.min.css 替换为主题提供的文件。这是我的项目中使用 spacelab 主题的工作代码:
                bundles.Add(new StyleBundle(GetStyleBundlePath("bootstrap")).Include(
                "~/Content/3rdParty/bootstrap.spacelab.css",
                "~/Content/3rdParty/bootstrap-datepicker.css",
                "~/Content/3rdParty/bootstrap-multiselect.css"));
    

    enter image description here

    关于asp.net - 缩小失败。返回未缩小的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24395412/

    相关文章:

    asp.net - 对 asp.net 包请求禁用 session 访问

    c# - 特定 session 超时

    c# - 使用模型值包括报价 ASP MVC4

    sql - 如何使用EF 6.0中的代码优先方法从sql表中删除列?

    c# - Web.Optimizations - 有什么方法可以从 Style/Script Bundle 中获取所有内容?

    ASP.NET bundle - 包含的文件更改后 bundle 未更新(返回 304 未修改)

    asp.net - 如何在powershell中执行具有[[FromForm]]参数的API PUT方法

    c# - 如何切换 .NET 程序集以执行一种方法?

    asp.net - 我如何使用 AJAX 来确定用户的 session 是否已过期,然后将其返回到登录页面?

    asp.net-mvc - 如何从我的模型中的剑道编辑器中获取值