Why is Sass striping semicolons?

2019-09-03 06:38发布

问题:

I'm using Compass to compile a Sass Zen theme. I got this warning:

 Compass has changed how browser support is configured. The following configuration         variables are no longer supported: $legacy-support-for-ie6, $legacy-support-for-ie7, $legacy-support-for-ie8

I installed older versions of

compass (0.12.7)
sass (3.2.19)
breakpoint (1.3)

I'm no longer getting the warning, however, I'm losing semicolons in the compiled code. Example:

/* Address paddings set differently in IE 6/7. */
menu,
ol,
ul {
padding: 0 0 0 $indent-amount; /* LTR */
}

@if $legacy-support-for-ie7 {
/* Correct list images handled incorrectly in IE 7. */
nav ul,
nav ol {
list-style: none;
list-style-image: none;
} 

Compiles to

menu,
ol,
ul {
padding: 0 0 0 30px 
/* LTR */
}

Notice the missing semicolon. It seems like everywhere there's an @if $legacy-support-for-ie compass then strips the preceding semicolon. There are 51 declarations of @if $legacy-support-for-ie in my files, I'd rather just leave them if possible.

回答1:

I've had issues with using the latest version of compass when a site was setup to use the pre 1.0 release of compass. Try using Compass 0.12.7 and then rebuilding your dependencies from there. https://rubygems.org/gems/compass/versions/0.12.7



回答2:

The $legacy-support-for-ie has nothing to do with the very last semicolon being dropped. That's a particular of Compass.

Sass does not care how your code is formatted as long as it is valid. When the CSS is generated, it follows the style rules dictated by the chosen output style for things like whitespace, indentation, punctuation, etc. You can only specify a different output style, not change the particulars of any given style.

Note that omitting the final semicolon is completely valid according to CSS.



标签: sass compass