【问题标题】:MVC4 bundling: Minification failed because of css3-feature?MVC4 捆绑:缩小因 css3 功能而失败?
【发布时间】:2013-10-22 02:06:03
【问题描述】:

我想使用 MVC4 捆绑和缩小,但我总是在未缩小的 css 文件中收到此错误消息作为注释:

/* Minification failed. Returning unminified contents.
(534,29): run-time error CSS1019: Unexpected token, found ' '
(534,29): run-time error CSS1019: Unexpected token, found ' '
(534,29): run-time error CSS1042: Expected function, found ' '
(534,29): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
(535,26): run-time error CSS1019: Unexpected token, found ' '
(535,26): run-time error CSS1019: Unexpected token, found ' '
(535,26): run-time error CSS1042: Expected function, found ' '
(535,26): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
(536,25): run-time error CSS1019: Unexpected token, found ' '
(536,25): run-time error CSS1019: Unexpected token, found ' '
(536,25): run-time error CSS1042: Expected function, found ' '
(536,25): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
(537,24): run-time error CSS1019: Unexpected token, found ' '
(537,24): run-time error CSS1019: Unexpected token, found ' '
(537,24): run-time error CSS1042: Expected function, found ' '
(537,24): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
 */

CSS中对应的行是:

width: -webkit-calc(100% - 0.5em);
width: -moz-calc(100% - 0.5em);
width: -ms-calc(100% - 0.5em);
width: -o-calc(100% - 0.5em);

我可以做些什么来缩小以使用 css3 的 calc 功能?

【问题讨论】:

    标签: asp.net-mvc css asp.net-mvc-4 bundling-and-minification


    【解决方案1】:

    我不确定您能否在当前的实现中使用它。我认为你有两件事对你不利。

    1. 根据http://www.w3.org/standards/techs/css#w3c_all,几乎所有内容仍然是工作草案。如果 System.Web.Optimization 中的某些内容会发生变化,并且从长远来看会导致更多问题,那么可能不值得付出努力。

    2. calc() 目前是 CSS Values and Units Module Level 3 的一部分,其中指出:

      以下功能存在风险,可能会在 CR 期间被丢弃:‘calc()’、‘toggle()’、‘attr()’。”

    因此,有了这些东西,微软可能还没有走在 CSS3 的前沿。诚然,这很可能是一个错误,因为该语法并非完全没有问题。希望他们尽快开源System.Web.Optimization,这样人们就可以解决这样的问题。但他们已经承诺将其开源近一年了。

    与此同时,您可以尝试将文件预先捆绑在您可以对其进行大量控制的计算机上。或者可以尝试不同的捆绑/缩小系统,例如 Cassette

    【讨论】:

    • 是的...谢谢。显然,MS 实现了我认为缩小所需的更多智能。我尝试了 Cassette,但还有一些我现在不记得的其他问题......
    • @Ollie 另一个想法是实现你自己的IBundleTransform 并使用一个可以满足你想要做的事情的缩小器。可能比你愿意做的工作要多。
    • caniuse.com 表明实际上所有现代浏览器都支持 calc() 并且它确实工作得很好。我决定使用此处描述的解决方法:stackoverflow.com/a/18570513/1155881 感谢 Microsoft! ;-( 现在缩小工作正常。
    【解决方案2】:

    我回答我自己的问题是为了告诉你我现在将 Bundle TransformerYUI Compressor 结合使用。这真的很好,语法与微软的方式非常相似。
    看看吧!

    【讨论】:

      猜你喜欢
      • 2012-01-29
      • 2012-12-25
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-01
      • 2023-03-03
      • 1970-01-01
      相关资源
      最近更新 更多