Output optimization helps your website load faster and use less data. It makes your stylesheets smaller and easier for browsers to read.
Why output optimization matters in SASS
// Example of compressed output style in Sass sass --style=compressed input.scss output.css
Output styles control how Sass writes the final CSS file.
Common styles include nested, expanded, compact, and compressed.
// Nested style example
body {
font-family: Arial, sans-serif;
}
body h1 {
color: blue;
}// Compressed style example
body{font-family:Arial,sans-serif}body h1{color:blue}This Sass code defines a primary color and uses functions to lighten and darken it for background and text colors. It shows how Sass variables and functions help keep styles consistent and easy to update.
When compiled with compressed output, the CSS file will be smaller and faster to load.
@use 'sass:color'; $primary-color: #3498db; body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: color.scale($primary-color, $lightness: 40%); margin: 0; padding: 1rem; } h1 { color: $primary-color; font-size: 2rem; margin-bottom: 1rem; } p { color: color.darken($primary-color, 20%); line-height: 1.5; }
Optimized output reduces file size, which helps your site load faster.
Compressed CSS is harder to read but great for live websites.
Use expanded or nested styles during development for easier debugging.
Output optimization makes your CSS files smaller and faster to load.
Use compressed style for live sites and nested or expanded for development.
Optimized CSS improves user experience, especially on slow connections and mobile devices.