Search code examples
lessphpstormwebstorm

Less File Watcher - Ignore certain files


I'm using the Less.css File Watcher with WebStorms and I would like to exclude specific files for compilation. I have one style.less file that includes all other CSS and only this file should be compiled. How can I do that?


Solution

  • If you need the file watcher to watch changes in a single .less file only, ignoring all changes in other .less files, this can be done using Scopes:

    • In Settings/Scopes add your custom scope, with needed files/folders excluded (see Scopes (Phpstorm Help) for more info).

    • In Settings/File Watchers, open your LESS file watcher settings and change the 'Scope' property value from 'Project Files' to your custom scope.

    If you need changes in all less files being watched, but have a single style.css generated that would include the styles from all .less files throughout the project, tick 'Track only root files' checkbox in your watcher settings. See the explanation in Help:

    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