How to Minify CSS with SCSS File Watcher in PHPStorm IDE

achucuan picture achucuan · Aug 1, 2013 · Viewed 24.3k times · Source

Is there a way to configure SASS FileWatcher so it builds a Minified CSS?

I currently configured SASS + YUI Compressor to accomplish this but I would like to do this with pure SASS if possible.

Here are the screenshots of both configurations:

SASS

YUI Compressor CSS

Thanks in advance.

Answer

E. Serrano picture E. Serrano · Mar 2, 2014

Probably the fastest way to achieve this is to use the compressed option, mentioned in the previous comments, as an argument. The quickest way to configure this in PHPStorm is as follows:

  • Go to File > Settings
  • Inside Project Settings select File Watchers
  • You should already have an SCSS watcher created here (if you have the SCSS watch plugin enabled, PHPStorm prompts you to create a watcher when opening a new .scss file.) Otherwise, enable it (more info about that in this section of the official documentation,) and then create the new watcher pressing the "+" symbol.
  • Double click the watcher name to access its configuration.
  • In the Arguments line make sure to add the --style compressed argument
  • Click OK and you're done

This image shows how that configuration should look:

Compressed SCSS settings in PHPStorm

From that point on, your .css output files will be compressed.