In this recipe, you will learn how to use the @debug
, @warn
, and @error
directives to debug your code or validate the input for mixins and functions.
This recipe requires the command-line Ruby Sass compiler installed. In the Installing Sass for command-line usage recipe of Chapter 1, Getting Started with Sass, you can read about how to install Ruby and Ruby Sass. You can edit the Sass templates with your favorite text editor.
Use the following steps to learn how to use the @debug
, @warn
, and @error
directives to debug your Sass code:
Create a Sass file
test.scss
that contains the following SCSS code:@mixin set-width($width) { @if $width < 50 { @error "width should be >= 50"; $width: 1px * $width; } @if unit($width) not 'px' { @warn "width (#{$width}) converted to pixels"; $width: 1px * $width; } $width: $width * 10; @debug "width: #{$width}"; width: $width; } div { @include set...