2

我的安装似乎很好,因为默认的“应用程序”集合有效。

但是,我尝试创建一个新集合,但似乎无法正确构建:

在我的 global.php 中(在文档中,它说它必须位于 config/packages 等中的某个位置,但我猜这仅适用于 Laravel 3?)我输入以下内容:

    Basset::collection('preview', function($collection)
    {
        $collection->stylesheet('stylesheets/bootstrap.min.css');
        $collection->stylesheet('stylesheets/bootstrap-responsive.min.css');
        $collection->javascript('javascripts/bootstrap.min.js');
    });

所以我想,只需使用工匠创建一个构建“预览”:

php artisan basset:build preview

输出:

[preview] Stylesheets build was not required for collection.
[preview] Javascripts build was not required for collection.

当我查看我的文件夹“builds”时,我只看到应用程序集合,没有看到添加了工作表/脚本的新文件夹“preview”。使用 @stylesheets('preview') 在我的视图中加载它也不会做任何事情。

有什么建议可以让它工作吗?谢谢!

4

3 回答 3

1

您确实需要在 config/packages 中添加一个由 Basset 插件获取的文件 - 最简单的方法是运行artisan config:publish jasonlewis/basset.

然后,将您的集合添加到collections数组中,例如:

'preview' => function($collection) {
    $collection->stylesheet('stylesheets/bootstrap.min.css');
    $collection->stylesheet('stylesheets/bootstrap-responsive.min.css');
    $collection->javascript('javascripts/bootstrap.min.js');
},

文档确实暗示您可以这样做,但我还没有弄清楚在哪里 - 但是这个配置方法确实有效。

于 2013-07-16T15:24:51.823 回答
0

尝试这个/

'collections' => array(

'application' => function($collection)
{
    // Switch to the stylesheets directory and require the "less" and "sass" directories.
    // These directories both have a filter applied to them so that the built
    // collection will contain valid CSS.
    $directory = $collection->directory('assets/stylesheets', function($collection)
    {
        $collection->requireTree();

    });

    $directory->apply('CssMin');
    $directory->apply('UriRewriteFilter');

    // Switch to the javascripts directory and require the "coffeescript" directory. As
    // with the above directories we'll apply the CoffeeScript filter to the directory
    // so the built collection contains valid JS.
    $directory = $collection->directory('assets/javascripts', function($collection)
    {
        $collection->requireDirectory();
        $collection->javascript('//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');
    });
}
于 2013-10-21T23:03:54.443 回答
0

发布配置后,使用php artisan config:publish jasonlewis/basset导航到 app\config\packages\jasonlewis\basset 并在那里编辑 config.php。

然后,将您的集合添加到集合数组中,例如:

    'collections' => array(

    'application' => function($collection)
    {
        // Switch to the stylesheets directory and require the "less" and "sass" directories.
        // These directories both have a filter applied to them so that the built
        // collection will contain valid CSS.
        $directory = $collection->directory('assets/stylesheets', function($collection)
        {
            $collection->requireDirectory('less')->apply('Less');
            $collection->requireDirectory('sass')->apply('Sass');
            $collection->requireDirectory();
        });

        $directory->apply('CssMin');
        $directory->apply('UriRewriteFilter');

        // Switch to the javascripts directory and require the "coffeescript" directory. As
        // with the above directories we'll apply the CoffeeScript filter to the directory
        // so the built collection contains valid JS.
        $directory = $collection->directory('assets/javascripts', function($collection)
        {
            $collection->requireDirectory('coffeescripts')->apply('CoffeeScript');
            $collection->requireDirectory();
        });

        $directory->apply('JsMin');
    },

    'login' => function($collection)
    {

        $directory = $collection->directory('assets/stylesheets', function($collection)
        {
            $collection->stylesheet('bootstrap.min.css');
            $collection->stylesheet('metro.css');
            $collection->stylesheet('font-awesome.css');
            $collection->stylesheet('style.css');
            $collection->stylesheet('style_responsive.css');
            $collection->stylesheet('style_default.css');
            $collection->stylesheet('uniform.default.css');
        });

        $directory->apply('CssMin');
        $directory->apply('UriRewriteFilter');

        $directory = $collection->directory('assets/javascripts', function($collection)
        {
            $collection->javascript('jquery-1.8.3.min.js');
            $collection->javascript('bootstrap.min.js');
            $collection->javascript('jquery.uniform.min.js');
            $collection->javascript('jquery.blockui.js');
            $collection->javascript('jquery.validate.min.js');
            $collection->javascript('app.js');
        });

        $directory->apply('JsMin');            

    }

),
于 2013-07-29T14:13:47.067 回答