0

背景:我使用的是 Ubuntu 12.04、PHP 5.5.1-2 和 Laravel 4。

当我运行时:

php artisan basset:build

我得到错误

{"error":{"type":"ErrorException","message":"preg_match(): 
Compilation failed: nothing to repeat at offset 0",
"file":"\/home\/ryan\/MyApp6\/vendor\/jasonlewis\/basset\
/src\/Basset\/Filter\/Filter.php","line":241}}

我的问题与此类似:How to make less to work with basset in laravel 4?

但是,我已经尝试了 LessphpFilter,并且我已经安装了 node.js ......我可以使用 node 手动编译样式表,但通过 basset 都不会为我工作。

例如,给定 mytest.less:

@color:blue;
body{
    background-color: red;
    color:@color;
}

MyApp/app/config/packages/jasonlewis/basset/config.php

'collections' => array(

    'mytest-css' => function($collection)
    {

        $collection->directory('assets/bs3/css', function($collection)
        {
            $collection->add('../less/mytest.less')->apply('Less');            
        })->apply('UriRewriteFilter')->setArguments(public_path());
    },
...

当我在浏览器中拉起页面时,背景是红色的,但文本仍然是黑色的。在 Chrome devtools 中,我可以看到一个编译好的 css 文件,但内容仍然是:

@color:blue;

body{
    background-color: red;
    color:@color;
}

我究竟做错了什么?即使是有关如何跟踪此问题的提示也将不胜感激-谢谢!

4

1 回答 1

0

LessphpFilter 是我需要的,在 app/config/packages/jasonlewis/basset/config.php

我还需要添加一个前导斜杠,如下所示:

'Less' => array('LessphpFilter', function($filter)
{
    $filter->whenAssetIs('/*.less')->findMissingConstructorArgs();
}),

我希望这对其他人有所帮助。

于 2013-08-23T06:40:35.737 回答