Question

Is there a convenient way to have SASS automatically prepend a comment to the beginning of each CSS output file? Specifically, when using Compasss I'd like to stick a brief warning telling designers not to edit the CSS directly and to point them to instructions on getting started with Compass. I use an output style of :compressed, which strips out comments that are in the input SCSS/SASS file.

If there isn't a convenient way to do this then I'll submit an issue/patch. I was thinking of adding an option named :output_prefix that takes a String that will be prepended to all output CSS files.

Was it helpful?

Solution

compressed strips out all comments. I suggest you put this in a property:

warning { do-not: "edit this file"; }

Regarding the proposed patch, I do not think this use case is compelling enough to warrant such a feature.

OTHER TIPS

From the SASS reference on comments:

When the first letter of a comment is !, the comment will be interpolated and always rendered into css output even in compressed output modes. This is useful for adding Copyright notices to your generated CSS.

So you could start your SASS file with something like this:

/*!
 * WARNING: Don't edit this file by hand! Instead, you should be using Compass.
 * (More information at http://compass-style.org/)
 */

Known bug in Sass. Fixed in master but not yet released:

https://github.com/nex3/sass/issues/784

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top