简体   繁体   English

使用CSS变量时,VS MVC Project CSS缩小失败

[英]VS MVC Project CSS Minification fails when using CSS variables

In Visual Studio, Minification is failing for me in my MVC project when I introduce any variables in my bundled css files. 在Visual Studio中,当我在捆绑的CSS文件中引入任何变量时,Minification在我的MVC项目中失败了。 Example: 例:

/* Minification failed. Returning unminified contents.
(3,5): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-'
(6,23): run-time error CSS1039: Token not allowed after unary operator: '-main-bg-color'
 */
:root {
    /*DEFAULT COLORS LINES*/
    --main-bg-color: rgb(34,34,34);
}
body{
background-color:var(--main-bg-color);
}

other minifiers work just fine, is there a way to fix this? 其他缩小器工作正常,是否可以解决此问题?

The BundlerMinifier library used in visual studio for magnifying CSS is currently unable to handle CSS variables. Visual Studio中用于放大CSS的BundlerMinifier库当前无法处理CSS变量。

This issue has been raised on github https://github.com/madskristensen/BundlerMinifier/issues/218 / https://github.com/xoofx/NUglify/issues/17 . 这个问题已经提出在github https://github.com/madskristensen/BundlerMinifier/issues/218 / https://github.com/xoofx/NUglify/issues/17

Hope this helps. 希望这可以帮助。

我最终实现了Sass作为双重解决方案,该解决方案既可以实现多种可变方法,又可以实现最小化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM