Search code examples
csslessphpstormprecompilefile-watcher

LESSC Compiling Included Files Into CSS


I have the following file structure:

--public_html/
  - css/
  - less/
    - _mixins.less
    - _variables.less
    - _theme.less
    - main.less

I am using PhpStorm with a File Watcher running LESSC from NPM.

My file watcher is as follows:

Program: /usr/local/bin/lessc
Arguments: --no-color $FileName$
Output paths to refresh: ../$FileNameWithoutExtention$.css

Files:

main.less:

@import "_variables.less";
@import "_mixins.less";
@import "_theme.less";

_theme.less contains my stylsheet and _variables.less and _mixins.less are all pretty self explanatory.

When I modify and save main.less The file main.css is created in the css folder as it should.

However, when I edit my _theme.less file, LESSC creates a _theme.css file, also.

How do I stop these extra files being created?

If you need any more info, please ask.


Solution

  • Please ensure that Track only root files option is enabled in that particular File Watcher settings -- it does just that.

    From https://www.jetbrains.com/help/phpstorm/2016.3/new-watcher-dialog.html#d199014e291

    When the File Watcher is invoked on a file, PhpStorm detects all the files in which this file is included. For each of these files, in its turn, PhpStorm again detects the files into which it is included. This operation is repeated recursively until PhpStorm reaches the files that are not included anywhere within the specified scope. These files are referred to as root files (do not confuse with content roots).

    • When this check box is selected, the File Watcher runs only against the root files.
    • When the check box is cleared, the File Watcher runs against the file from which it is invoked and against all the files in which this file is included recursively within the specified scope.