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

后端 未结 6 500
误落风尘
误落风尘 2020-12-09 09:30

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:

相关标签:
6条回答
  • 2020-12-09 09:34

    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

    0 讨论(0)
  • 2020-12-09 09:35

    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.

    0 讨论(0)
  • 2020-12-09 09:38

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

    0 讨论(0)
  • 2020-12-09 09:41

    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.

    0 讨论(0)
  • 2020-12-09 09:42

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

    0 讨论(0)
  • 2020-12-09 09:49

    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

    0 讨论(0)
提交回复
热议问题