Is there a way to have Sass print out a variable to the terminal?
Asked
Active
Viewed 4.5k times
54
-
1Are you trying to log to the devtools in Chrome/Firefox or to the terminal when running sass? – imjared Sep 11 '13 at 03:32
1 Answers
105
Sass 3.3 and older
There are 2 error related directives:
The @debug directive prints the value of a SassScript expression to the standard error output stream.
@debug 10em + 12em;
outputs:
Line 1 DEBUG: 22em
The @warn directive prints the value of a SassScript expression to the standard error output stream. It's useful for libraries that need to warn users of deprecations or recovering from minor mixin usage mistakes.
@warn 'This is a warning';
Sass 3.4 and newer
The @error directive throws the value of a SassScript expression as a fatal error, including a nice stack trace. It’s useful for validating arguments to mixins and functions. For example:
@error 'This is an error';
.foo {
background: red;
}

cimmanon
- 67,211
- 17
- 165
- 171