gulp的gulp-clean-css压缩插件参数问题?

clipboard.png

如图,compatibility这个参数似乎是“适应”的意思,这就搞不懂了,压缩个代码还要考虑兼容ie8的吗?

阅读 4.2k
3 个回答

gulp-clean-css底层用的是clean-css,更多参数可以看clean-css的内容。

关于这个参数: 其文档也有说明>>

For example, this declaration --compatibility 'ie8,+units.rem' will ensure IE8 compatiblity while enabling rem units so the following style margin:0px 0rem can be shortened to margin:0, while in pure IE8 mode it can't be.

要考虑。部分 CSS hack 是针对某些版本的浏览器的。例如:


body {
  _property: value; /* IE6 */
  +property: value; /* IE7 */
  property: value\0; /* IE6 && IE7 */
}

在你设置 compatibility 为 IE8 时,那上面这些其实是不必要的!

这是告诉cleancss压缩时要不要保留IE8及以下兼容写法,写compatibility:'ie7'就是保留ie7兼容写法。。比如zoom:1;这些,不保留它就给你删除了。。
压缩插件不仅仅是压缩,还能优化,如果你用gulp-cssnano,还能帮你把多余的类名和属性合并。。等等

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题