Yii Framework Forum: Less Extension Not Working In Server Mode - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Less Extension Not Working In Server Mode Rate Topic: -----

#1 User is offline   sandro1111 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 07 March 2013 - 05:33 AM

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?
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 07 March 2013 - 05:34 AM

/* moved from General Discussion */

What extension is it?
"Less noise - more signal"
0

#3 User is offline   sandro1111 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 07 March 2013 - 06:21 AM

View Postjacmoe, on 07 March 2013 - 05:34 AM, said:

/* moved from General Discussion */

What extension is it?


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


The discussion has been started in the extension's comment area...

This post has been edited by sandro1111: 11 March 2013 - 09:28 AM

0

#4 User is offline   sandro1111 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 11 March 2013 - 09:37 AM

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"

0

#5 User is offline   sandro1111 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 12 March 2013 - 03:31 AM

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 . '"';

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users