23

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.

10
  • IIRC this was outlined in the demo video of the feature. Do you know which video I mean? Commented Apr 12, 2013 at 0:52
  • No, I don't. Can you please provide a link? Commented Apr 12, 2013 at 1:02
  • ../css/filename.css -- will go one level up and then in css folder (relative to the current file). For deeper location (css/dir/file.less) I think you will have to use separate file watcher with different scope ("Settings | Scopes"). If that will not work, then better stick with simpler folder structure. Commented Apr 12, 2013 at 1:05
  • @aaronp: youtube.com/watch?v=TtdIm1EKLBk I think it was, looking for the blog-post now. Commented Apr 12, 2013 at 1:08
  • 1
    @M8R-1jmw5r, actually you can, see my answer. Commented Apr 12, 2013 at 7:08

6 Answers 6

43

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Setting output paths to refresh value to '$ProjectFileDir$\www\catalog\view\theme\mytheme\js' worked for me on Windows env. ~ as a future reference for myself
10

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

enter image description here

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..

2 Comments

Worth mentioning is that I got problems when an "Output path to refresh" was given and "Create output file from stdout" was checked... When I unchecked "Create output file from stdout" everything worked fine.
I pretty much did the same thing. Not sure if it is noteworthy or not, but I had an extra colon in my arguments. --no-cache --update $FileName$:../css/$FileNameWithoutExtension$.css
5

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

4 Comments

I found this to be the simplest solution.
My first thoughts were to do this but it didn't work for me.
What exactly doesn't work out for you? You don't see a file being created?
@Radmation reverse slashes in path
0

To change output directory for less compiler.
Open edit watcher in tat you will see output paths to refresh in that input box change as like this ../yourfolderpath/$FileNameWithoutExtension$.css. Now you can see less compiles .css to this path.

Comments

0

I had a similar problem with getting scss file watcher to output to the css directory

This is what I did.

  1. In Arguments, --no-cache --update $ProjectFileDir$/css/style.css
  2. In Output paths to refresh, $ProjectFileDir$/css/$FileDirPathFromParent(scss)$$FileNameWithoutExtension$.css

You can modify this to work with LESS

Comments

-2

You may want to try SimpLESS as a watcher for checking/compiling LESS to CSS on the fly - free to use on all platforms.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.