ASP.NET MVC Bundle 按照相关网上教程配置完成后合并成功了,但是CSS并没有压缩成功,合并文件中有如下错误提示
/* Minification failed. Returning unminified contents. (26935,21): run-time error CSS1036: Expected expression, found ''' (26935,1525): Scanner error CSS1002: Unterminated string: '%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); (26941,21): run-time error CSS1036: Expected expression, found ''' (26941,1522): Scanner error CSS1002: Unterminated string: '%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); (36741,24): run-time error CSS1062: Expected semicolon or closing curly-brace, found '' (38890,29): run-time error CSS1062: Expected semicolon or closing curly-brace, found '' (39704,16): run-time error CSS1038: Expected hex color, found '#1a1915333' (42293,15): run-time error CSS1031: Expected selector, found '' (42293,15): run-time error CSS1025: Expected comma or open brace, found '' (42302,11): run-time error CSS1030: Expected identifier, found ' ' (43578,1): run-time error CSS1019: Unexpected token, found '}' (44883,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes' (44884,8): run-time error CSS1035: Expected colon, found '{' (44891,1): run-time error CSS1019: Unexpected token, found '@keyframes' (44892,8): run-time error CSS1035: Expected colon, found '{' (48552,5): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes' (48553,14): run-time error CSS1035: Expected colon, found '{' (48564,5): run-time error CSS1019: Unexpected token, found '@keyframes' (48565,14): run-time error CSS1035: Expected colon, found '{' (48920,81): run-time error CSS1062: Expected semicolon or closing curly-brace, found '=' (49450,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes' (49451,2): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%' (49459,1): run-time error CSS1019: Unexpected token, found '@-moz-keyframes' (49460,2): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%' (49468,1): run-time error CSS1019: Unexpected token, found '@keyframes' (49469,2): run-time error CSS1062: Expected semicolon or closing curly-brace, found '0%' (50493,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes' (50494,8): run-time error CSS1035: Expected colon, found '{' (50501,1): run-time error CSS1019: Unexpected token, found '@keyframes' (50502,8): run-time error CSS1035: Expected colon, found '{'
上面的错误以注释的方式出现在文件中,实际中貌似没有对我的网站造成特别的影响,但是后面的内容没有压缩。
于是想是不是因为上面的错误,导致合并成功但是没有压缩成功呢,与是就是一个排除上面的错误。
虽然上面有说明行号,但是没有用啊~~于是突然想起来自己的VS中有按照了一个压缩的软件《Bundler___Minifier》
安装完成后,可以直接右键点击CSS文件进行单独压缩,如果有错误,可以在VS的【输出】中很方便的看出来。
在单独压缩时遇到一个问题:"路径中具有非法字符。"
原因:存在跨域的路径 例如:图片可能应用了其他网络的路径图片!
在VS中对每个CSS单独压缩测试后,发现与上面的错误提示其实是一样的啊!!哈哈。
对每个错误都排查后,重新合并压缩,就没有问题了。
总结:一定要使用Bundler___Minifier对每个错误都排查掉,确保每个文件单独压缩都没有问题,这样在bundler时,才能成功合并并压缩。
欢迎大家来我的网站逛逛:www.wastois.com
微信公众号:搜索wastois
微信公众号/网站定制服务:加QQ:380899422咨询!(只接.NET订制项目)