Performance: SASS with PostCSS pipeline
This affects the CSS build time and the final CSS file size, impacting page load speed and render blocking.
Jump into concepts and practice - no test required
@use 'main'; // single entry point with consolidated imports .post { color: red; } // PostCSS configured with autoprefixer and cssnano for minification
@import 'many-partials'; // many small files imported individually .post { color: red; } // PostCSS plugins run without minification or autoprefixing
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Many small SASS imports without PostCSS optimization | N/A | N/A | High due to large CSS | [X] Bad |
| Single SASS entry with PostCSS autoprefixer and minification | N/A | N/A | Low due to small optimized CSS | [OK] Good |
$color: blue;
.button {
color: $color;
display: flex;
}$main-color: red;
.container {
color: $main-color;
display: flex;
}// SASS variables
$btn-color: green;
// SASS nested styles
.button {
color: $btn-color;
display: flex;
&:hover {
color: darkgreen;
}
}
// PostCSS autoprefixer runs after SASS compilation