5CSS Output Styles

When you compile your Sass, a CSS file is generated. But what if you want that CSS file to be in a different format? If you compile your Sass on the command line, you have a few options to choose from. This means you can have your CSS output in a style that you prefer.

If you installed the Ruby version of Sass, in the command line, you can type this:

 sass --style

If you installed the Node version of Sass, you can type this instead:

 node-sass --output-style

Follow this with the name of the style you want. The four options you can choose from are called nested, expanded, compact, and compressed. For example, here’s how you would use the Ruby version of Sass to output a compressed file:

 sass --style compressed input.scss ...

Get Pragmatic Guide to Sass 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.