Here is a one-liner that compiles your SASS or SCSS files into compressed CSS.
Use the following command to install the sass Ruby gem:
Compress Indented Syntax Sass Files
Compress Bracketed Syntax SCSS Files
or alternatively, you can use the
scss command line tool (which is installed with the sass gem) that defaults to the SCSS syntax. This avoids the need for the
Use with Compass
If you are using Compass in your project, add the
--compass switch to your command so that the Compass imports are available during the compile.
Create an Alias
Save the command as an alias in your bash startup file (
~/.bashrc) to make it quick and easy to use. Let’s call it ccss for ‘compressed css’:
If you want to use the alias in the open terminal window, run a source command on your bash startup file. For .bash_profile it would look like this:
source ~/.bash_profile. You won’t need to do this again the next time that you open the terminal. The alias will automatically load in the new shell process that you launch.
Then use it on the command line by adding your file paths for the input SCSS file and output CSS file:
Have a look through the SASS documentation on the
--watch switch which indicates that sass should watch for changes in your SCSS or SASS files and automatically compile CSS files from the changes. This may be a better fit for your development workflow than these manual compression commands.