Sass: print to terminal

一个人想着一个人 提交于 2019-12-30 01:34:06

问题


Is there a way to have Sass print out a variable to the terminal?


回答1:


Sass 3.3 and older

There are 2 error related directives:

@debug

The @debug directive prints the value of a SassScript expression to the standard error output stream.

@debug 10em + 12em;

outputs:

Line 1 DEBUG: 22em

@warn

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

@error

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;
}


来源:https://stackoverflow.com/questions/18729192/sass-print-to-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!