Is there a version of YUI Compressor that deals correctly with media queries?

时光毁灭记忆、已成空白 提交于 2019-11-27 15:55:09

问题


YUI Compressor has a known bug where some media queries, including those used to serve styles to iOS and Android devices (e.g. @media screen and (max-device-width: 480px) {...}), are broken when compressed, because the space between the and and the opening brace is removed.

  • http://yuilibrary.com/projects/yuicompressor/ticket/2527991

The latest version available for download from the homepage (2.4.2) still has this issue.

  • http://yuilibrary.com/downloads/#yuicompressor

Is there an updated version available where this issue is fixed?


回答1:


If you have to get this working in 2.4.2, use the preserve comments hack (normally used for copyright messages).

@media screen and/*!YUI-Compressor */(max-device-width: 480px) {...}



回答2:


Yes — this issue is fixed in 2.4.4, which is downloadable from YUI Compressor’s git project:

  • https://github.com/yui/yuicompressor/archives/yuicompressor-33

This version seems to work, at least on Mac OS X 10.6.4.

Instructions:

  1. Download the zipped source from the page above, and unzip it.
  2. In the Terminal, change into the unzipped source folder.
  3. Type ant and hit return. This will create a folder called build, and put the built jar file in it. The built jar file is called yuicompressor-2.4.5pre.jar
  4. Change into the build folder, and run chmod +x yuicompressor-2.4.5pre.jar to make the jar file executable.
  5. Optionally, move the jar file into /usr/local/bin/
  6. Optionally, create an alias in your .profile file to make it easier to run, e.g. alias yuic="java -jar /usr/local/bin/yuicompressor-2.4.5pre.jar"


来源:https://stackoverflow.com/questions/4144706/is-there-a-version-of-yui-compressor-that-deals-correctly-with-media-queries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!