Search code examples
csslessphpstorm

PHPStorm: How do I setup LESS to output to CSS directory with file watcher?


How do, using File Watchers in PHPStorm do I set up LESS file watchers output path to do this:

I want:

/project/path/less/dir/file.less

to output to:

/project/path/css/dir/file.css

or

/project/path/less/file2.less

to output to:

/project/path/css/file2.css

I'm not seeing a clear way to make this happen with the Output Path macros in PHPstorm. With the FileDirRelativeToProjectRoot macro, I'm able to get the path to the current directory, but there is no clear way to replace /less with /css in the path.


Solution

  • See my related answer for JADE file watcher, I believe it would be the same for LESS.

    The trick is to use $FileDirPathFromParent(dir)$ macro:

    $ProjectFileDir$/css/$FileDirPathFromParent(less)$ will produce /project/path/css/dir/ for a file located in /project/path/less/dir/ directory.