Every time I come across this question and with a long time looking for an answer to the English-speaking stackOverflow.

In PHPStorm, you need to compile a minimized .css file from .less on the fly. File Watcher is configured, the file is compiled properly, but what flag should I add to the arguments to get the minimized file?

enter image description here

    1 answer 1

    Introduction

    The code in this section is not the answer!

    Having unsuccessfully tried to find an answer to my question (I was probably looking badly), I decided to do what I should have done from the very beginning - look in the help node-module less. Having executed the command, I received an exhaustive answer -

    -x, --compress Compresses output by removing some whitespaces. 

    Here it is! - I thought, added the --compress flag in the File Watcher settings and got ... minimized warning file

     The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.html 

    Then I proceeded to the page https://github.com/less/less-plugin-clean-css , where I found the final, working instruction.

    Work Answer

    You need to additionally install the module less-plugin-clean-css with the command

     npm install -g less-plugin-clean-css 

    and then add to Watcher's arguments

     --clean-css="--s1 --advanced --compatibility=ie8" 

    in the end, the Watcher settings in my case looked like this:

    enter image description here

    The file is minimized, but with saved comments. A description of all the arguments to the clean-css module can be found at https://github.com/jakubpawlowicz/clean-css . There I found the answer, how to minimize comments when minimizing :

    it is required to add the --s0 flag to the arguments for --clean-css (in my case, correct the existing --s1 flag) in this way:

      --clean-css="--s0 --advanced --compatibility=ie8"