What output styles remove multi-line strings?

In a SCSS file that displays style ( nested, extended, compact, or compressed ) will remove multi-line ( /* I'm a comment. */ ) Comments from the final CSS?

+7
source share
3 answers

:compressed is the only output style that removes multi-line ( /* ... */ ) comments from final CSS rendered.

Additionally: compact converts a multi-line comment into a single line in the last CSS. With: nested and: extended, all multi-line comments and their line breaks are displayed in the final CSS.

For example, this SCSS:

 // SL Comment /* ML Comment1 Whoop. */ //! SL w/ bang /*! ML Comment2 Whoop. */ 

will be the following CSS for each output style:

Nested:

 /* ML Comment1 Whoop. */ /* ML Comment2 Whoop. */ 

Expanded:

 /* ML Comment1 Whoop. */ /* ML Comment2 Whoop. */ 

Compact:

 /* ML Comment1 Whoop. */ /* ML Comment2 Whoop. */ 

Compressed:

 /* ML Comment2 Whoop. */ 

Post a comment with ! only affects multi-line comments in :compressed mode, where they will be saved if they are otherwise removed from the final CSS.

+10
source

Even if the output style is "compressed", I was not able to delete multi-line comments, and the sass / scss documentation also assumes that they are not deleted (only single-line comments with "//" are deleted).

My solution was to simply use single-line Perl to manually remove comments from the .css file after sass generated its final output:

 sass -fCE utf-8 -t compressed application.sass application.css perl -pi -e'BEGIN{$/=undef}s#/\*.*?\*/##gs' application.css 
+1
source

This is a shame, I can neither omit or comment on the accepted answer. According to the document, what was written and accepted is simply incorrect. Sass only deletes single-line codes and saves multi-line comments.

Sass supports standard multi-line CSS comments with / * * /, as well as single-line comments with //. Multi-line comments are stored in the CSS output where possible, while single-line comments are deleted.

See the docs here.

-one
source

All Articles