在过去的一年里,我使用System.Web.Optimization Bundling& Minificaiton。虽然我还不是专家,但我几乎都知道它的大部分商品和坏事。
我遇到的一个问题是 CSS捆绑:当您尝试将多个文件缩小为一个捆绑包时,如果一个文件中有一些内容无法缩小,那么整个捆绑包仍然没有通过顶部评论:
/ 缩小失败。返回未经宣传的内容。*
在这种情况下,虽然90%的缩小工作,但是单个文件可能会影响决策,或者捆绑是否缩小。
这是一个例子 (看起来像@ keyframes,@ import,@ -moz- ..和这样的标记,但不仅仅是这些因素会导致缩小时的运行时错误)
/* Minification failed. Returning unminified contents.
(518,32): run-time error CSS1019: Unexpected token, found ' '
(518,32): run-time error CSS1019: Unexpected token, found ' '
(518,32): run-time error CSS1042: Expected function, found ' '
(518,32): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
(569,32): run-time error CSS1019: Unexpected token, found ' '
(569,32): run-time error CSS1019: Unexpected token, found ' '
(569,32): run-time error CSS1042: Expected function, found ' '
(569,32): run-time error CSS1062: Expected semicolon or closing curly-brace, found ' '
(1209,1): run-time error CSS1019: Unexpected token, found '@CHARSET'
(1209,10): run-time error CSS1019: Unexpected token, found '"UTF-8"'
(1209,17): run-time error CSS1019: Unexpected token, found ';'
(1445,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes'
(1446,3): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%'
(1449,1): run-time error CSS1019: Unexpected token, found '@-moz-keyframes'
(1450,3): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%'
(1457,1): run-time error CSS1019: Unexpected token, found '@-ms-keyframes'
(1458,3): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%'
(1461,1): run-time error CSS1019: Unexpected token, found '@keyframes'
(1462,3): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%'
(1521,2): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes'
(1522,8): run-time error CSS1035: Expected colon, found '{'
(1530,2): run-time error CSS1019: Unexpected token, found '@keyframes'
(1531,8): run-time error CSS1035: Expected colon, found '{'
....
*/
我知道有一些名为Transformers的东西(不确定它是否是唯一的方法),但我真的无法通过相关示例找到任何易于理解的资源。 我想要达到的目标是,如果文件不能缩小,只需将其保持在未分层状态,但在同一个捆绑包定义中。
例如,如果我有file1.css,file2.css,file3.css,并且只能将file2.css缩小,我希望在我的包中看到下一个结果:
<content of file1.css minified>
<content of file2.css unminified>
<content of file3.css minified>
希望有人可以提供帮助