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.
Creating a File WatcherIn the Settings/Preferences dialog ( Ctrl+Alt+S ), click File Watchers under Tools. The File Watchers page opens showing a list of File Watchers that are already configured in this project and in the IDE. and choose the predefined template from which you want to create a File Watcher.
To start, create a folder with two folders inside, CSS and images. Then inside the CSS folder create a file with the Sass extension – in my case it's style. scss. Then open it and the file will be detected right away.
File Watcher is an IntelliJ IDEA tool that allows you to automatically run a command-line tool like compilers, formatters, or linters when you change or save a file in the IDE.
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.
I want to compile one less file from
sites/all/themes/bic/res/less/style.less to sites/all/themes/bic/res/css/style.css
Here's what I did
So the Arguments I used is: --no-color $FileName$ ../css/$FileNameWithoutExtension$.css
This will produce: /usr/local/bin/lessc --no-color blogs.less ../css/blogs.css at phpstorm console, and works fine.
I might miss something. Anyway, I tried both "--no-color $FileName$ $ProjectFileDir$/sites/all/themes/bic/res/css/$FileDirPathFromParent(less)$" and "--no-color $FileName$ $ProjectFileDir$/sites/all/themes/bic/res/css/$FileDirPathFromParent(less)$$FileNameWithoutExtension$.css". Neither of them work for me. So just post my solution here, which might help some people who has the same trouble with me..
Just change Output Path to Refresh to:
../css/$FileNameWithoutExtension$.css
Update:
In the new version of LESS you should reverse your slashes in Path you specify. So it should be:
..\css\$FileNameWithoutExtension$.css
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With