SASS: preserve comment position

966 Views Asked by At

I recently decided to use RTLCSS to make RTL versions of my stylesheetes. Now i'm trying to use Declaration-level directives to tell RTLCSS what to do, but SASS compiles my comments to next line.

For example, font-size: 14px/*rtl:15px*/; Compiles to

font-size: 14px;
/*rtl:15px*/

And that stops RTLCSS from procssing it properly. Is there a way around this? can i configure sass to just compile the value as-is, preserving comment position?

P.S. I use grunt-sass(node-sass) to process my scss files.

2

There are 2 best solutions below

0
On BEST ANSWER

Use SASS interpolation syntax, passing your comment as string

body{ font-size: 14px #{"/*rtl:15px*/"}; }

will produce

body { font-size: 14px /*rtl:15px*/; }
0
On

Both standard /rtl:.../ and special/important /!rtl:.../ notations are supported.

You can use /!rtl: to escape from sass compiler

Documentation