Less Extension Not Working In Server Mode

I’ve got some problems with using different less files for showing different styles in different areas of one application. With client side mode I used this code in the header of protected/views/layouts/main.php:




Yii::app()->less->files = array('less/instance.less'=>'css/instance.less');

Yii::app()->less->register();



Now I changed to server side mode and can’t get it to work. With the code from client side mode it didn’t work so I changed to only register less in the layouts/main.php’s header. I also tried to use multiple instances of the compiler but this seems not to work too. The code therefore looked like that:




'lessArea1'=>array(

    'class'=>'ext.less.components.Less',

    'mode'=>'server',

    'files'=>array(

        'less/area1.less'=>'css/area1.less',

        'less/styles.less'=>'css/styles.less',

    ),

    'options'=>array(

        'nodePath'=>'/my/path/to.js',

        'compilerPath'=>'/my/path/to/lessc',

        'strictImports'=>true,

        'forceCompile'=>true,

    ),

),

'lessArea2'=>array(

    'class'=>'ext.less.components.Less',

    'mode'=>'server',

    'files'=>array(

        'less/area2.less'=>'css/area2.less',

        'less/styles.less'=>'css/styles.less',

    ),

    'options'=>array(

        'nodePath'=>'/my/path/to.js',

        'compilerPath'=>'/my/path/to/lessc',

        'strictImports'=>true,

        'forceCompile'=>true,

    ),

),



And of course I changed the register code to register lessArea1 and lessArea2. But it was always the same, I had always the same style in both areas.

Compiling less files manually with lessc works perfectly…

Does anyone have an idea what I’m doing wrong or an hint how I could do this better?

[color="#006400"]/* moved from General Discussion */[/color]

What extension is it?

It is the less extension from here: http://www.yiiframework.com/extension/less/

The discussion has been started in the extension’s comment area…

Okay, I’ve searched again for the problem but I still couldn’t find out what’s wrong… For testing purpose I changed my code to be easier to test because multiple instances of the compiler wouldn’t be the best solution…




// server side version

'less'=>array(

	'class'=>'ext.less.components.Less',

	'mode'=>'server',

	'files'=>array(

		'less/file1.less'=>'css/file1.less',

		'less/file2.less'=>'css/file2.less',

		'less/file3.less'=>'css/file3.less',

	),

	'options'=>array(

		'nodePath'=>'/usr/local/lib/node_modules/npm/bin/npm-cli.js',

		'compilerPath'=>'/root/.npm/less/1.3.3/package/bin/lessc',

		'strictImports'=>true,

		'forceCompile'=>true,

	),

),



I have to say the nodePath on my first post was wrong but now it should be the correct path. The error message I’m getting is the following:




"NetworkError: 404 Not Found - http://myurl.com/css/file1.less"

"NetworkError: 404 Not Found - http://myurl.com/css/file2.less"

"NetworkError: 404 Not Found - http://myurl.com/css/file3.less"



Finally I found the solution… The problem was the command executing the compiler. It seems to have some wrong syntax the the less version I have installed. I changed the command and now it works like a charm.




$command = 'lessc ' . implode(' ', $options) . ' "' . $lessPath . '" > "' . $cssPath . '"';