Sass "Undefined variable" - Fix in CI
Sass reached a $variable it has no value for. Either the partial that defines it was never loaded, or it now lives behind a @use namespace and the bare name no longer resolves.
What this error means
Compilation fails with SassError: Undefined variable. pointing at the $name usage. Often appears right after migrating @import to @use.
SassError: Undefined variable.
╷
8 │ color: $primary;
│ ^^^^^^^^
╵
src/styles/button.scss 8:10 root stylesheetCommon causes
Variable partial not loaded
The file using $primary never @uses or @imports the partial that defines it.
Missing @use namespace
With @use 'variables', members are namespaced - $primary must be variables.$primary unless you @use 'variables' as *.
How to fix it
Load the partial and namespace the member
- Add the
@useat the top of the file. - Reference the variable through its namespace.
@use 'variables';
.button { color: variables.$primary; }Import all members into scope
- When you want the legacy bare-name behavior, alias the module to
*.
@use 'variables' as *;
.button { color: $primary; }How to prevent it
- Standardize on
@usewith explicit namespaces across the codebase. - Keep shared variables in one entry partial that every component loads.