Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LESS minifier breaking media queries on possible comment parse #1349

Closed
bmcminn opened this issue Jun 2, 2013 · 5 comments
Closed

LESS minifier breaking media queries on possible comment parse #1349

bmcminn opened this issue Jun 2, 2013 · 5 comments

Comments

@bmcminn
Copy link

bmcminn commented Jun 2, 2013

Posted this initially on the PrePros issues, https://github.com/sbspk/Prepros/issues/55

Problem persisted when minifying compiled LESS file with native LESS minifier with PrePros 1.5 on Windows 7 64-bit. Confirmed this same problem in Codekit's use of the LESS minifer (YUI compression) on Mac OSx 10.8.

EDIT: Possibly related issue #284


Noticed this in Chrome Version 27.0.1453.94m however it doesn't seem to affect FF 21, not sure about others.

This is a default media query definition per main.css - line 223 in the HTML5 Boilerplate template.

@media print,
       (-o-min-device-pixel-ratio: 5/4),
       (-webkit-min-device-pixel-ratio: 1.25),
       (min-resolution: 120dpi) {
    /* Style adjustments for high resolution devices */
    // a {
    //   font-size: 4rem;
    // }
}


/**===================================================**\
/**  PRINT STYLES
/**===================================================**/
@media only print {
  // *                             { background: @trans !important; box-shadow: none !important; color: @black !important; text-shadow: none !important; }
  a,
  a:visited                     { text-decoration: underline; }
  a[href]:after                 { content: " (" attr(href) ")"; }
  abbr[title]:after             { content: " (" attr(title) ")"; }

  /** MANUALLY TRUNCATED FOR BREVITY **/
}

When compressing the above LESS/CSS, the minified source breaks resulting in the following result:

@media print,(-o-min-device-pixel-ratio:5/@media only print{a,a:visited{text-decoration:

Looks like the minifier has an issue with / chars in @media definitions and I'm assuming treats it as a delimiter for a comment.

This particular issue causes @media scope to bleed into my only print media query, so my print styles are shown regardless of which media mode is enabled when my compressed CSS file is being used.

@lukeapage
Copy link
Member

Looks to be a bug in ycssmin - if you just use the basic compressor then you don't get any problem

@lukeapage
Copy link
Member

both ycssmin and cssmin which we used before that don't seem to be getting alot of development. https://npmjs.org/package/clean-css looks like it does.. we should consider switching. @jonschlinkert @matthew-dean do you know of any other node css minifiers and have any preferences?

@lukeapage
Copy link
Member

related: #1080

@lukeapage
Copy link
Member

clean css also has a issue - clean-css/clean-css#117
I think its caused by the *\ at the bgeining of the print styles comment block

@GoalSmashers
Copy link

It's fixed in clean-css 1.0.11. It was related to escaping new line breaks. Enjoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants