Debug Compilation Errors and Warnings
Sass errors can originate from invalid syntax, undefined variables, missing modules, incorrect function arguments, invalid map keys, incompatible units, or unsupported language features.
Start with the first meaningful compiler error rather than fixing every reported line independently. A single missing brace or invalid expression can trigger multiple follow-up errors.
Use @error when invalid inputs should stop compilation and @warn when a condition deserves attention but compilation can continue. These directives are especially valuable in shared mixins and design-system functions.
Deprecation warnings should be investigated rather than ignored indefinitely. Modern Dart Sass has removed some legacy features, and deprecated functions or import patterns may eventually stop working after an upgrade.
@use "sass:map";
$spacing: (
sm: 0.5rem,
md: 1rem,
lg: 1.5rem
);
@function spacing($name) {
@if not map.has-key($spacing, $name) {
@error "Unknown spacing token: #{$name}";
}
@return map.get($spacing, $name);
}
.card {
padding: spacing(md);
}Which directive should be used when an invalid Sass input must stop compilation?