问题
How to enable Less compiling with basset? My basset config file collection:
'collections' => array(
'application' => function($collection)
{
$collection->apply('UriRewriteFilter');
$directory = $collection->directory('../app/assets/stylesheets', function($collection)
{
$collection->add('less/design.less')->apply('Less');
});
$directory->apply('CssMin');
}
);
Everything else in config is untouched.
In the source code i get this:<link rel="stylesheet" type="text/css" href="http://localhost/Job/public/ph7mOzIaRTYLhvwL/application/6f5128120be8f13c4a2109051990f113/design.css" />
Even thought it's .css but it's not compiled into it.
Less filter
'Less' => array('LessFilter', function($filter)
{
$filter->whenAssetIs('*.less')->findMissingConstructorArgs();
}),
I'm using windows.
回答1:
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)
回答2:
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.
来源:https://stackoverflow.com/questions/16751054/how-to-make-less-to-work-with-basset-in-laravel-4