How to make less to work with basset in laravel 4?

柔情痞子 提交于 2019-12-05 17:26:15

Instead of using the node.js builder for less you can also use the php less builder:

Add the following require to your composer.json:

"require": {
    "leafo/lessphp": "*"
}
composer update

Change the Less filter alias in your basset config file to:

'Less' => array('LessphpFilter', function($filter)

I just had this problem and was going a little bit mad trying to work it out. I'm working on Mac OS X, but it could be the same issue - ie. it looked like it had compiled and I got the long CSS filename exactly like you did, but the LESS had not compiled.

I saw in the error log for Basset the following:

[2013-06-03 20:13:13] basset.ERROR: Failed to find required 
constructor argument for filter "LessFilter". 
(Parameter #0 [ <optional> $nodeBin = '/usr/bin/node' ])

So I realised that the LESS filter was looking for Node.js to do the actual compiling. I didn't have Node.js installed... so I installed it, and ran php artisan basset:build application again.

It worked.

So have you got Node.js installed? If not, I think you need to do that. Then you'll need to install the actual modules, for example npm install less will install LESS when run from the command line.

Once you've done that, Windows is a little bit more tricky to inform about the path to executables (ie. the LESS compiler), so you might need to enter some paths yourself. There's more info here: http://jasonlewis.me/code/basset/4.0/filters#filter-executables under the "Windows Compatibility" section.

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!