Providing features that don't exist (or haven't existed) natively in CSS. For example, nesting, mixins, functions or inheritance.
@mixin mobile-only {
@media (max-width: $mobile-width) {
@content;
}
}
.root {
@include mobile-only {
display: none;
}
}
@function spacing($space) {
@if $space == 4 {
@return "4px";
} @else if $space == 8 {
@return "8px";
}
...
}
.root {
padding: spacing(4);
}
Analyse your needs before blindly adding one to your project.
With the evolution of CSS in the past years most use cases for preprocessors are easily solvable without them.
Vendor prefixes allow us to use newer features not yet considered stable. This approach is falling out of favor though.
-webkit-
: Chrome-based browsers, Safari-moz-
: Firefox-ms-
: IE, old Edge (no longer relevant)-o-
: Opera (no longer relevant)Mastering your browser's dev tools is essential. They allow you to:
Automated visual regression testing using screenshots allows teams to replace manual testing of UI components and pages. It ensures consistency of the UI.