CodeSleeve / asset-pipeline

This Laravel 4 package provides a very simple and easy to use asset pipeline. It was heavily inspired by the Rails asset pipeline. We make use of the wonderful Assetic package to help with pre-compliation!
http://www.codesleeve.com
MIT License
489 stars 53 forks source link

Adding paths at runtime #175

Closed ilkermutlu closed 6 years ago

ilkermutlu commented 10 years ago

I'm having a similar problem with this issue: https://github.com/CodeSleeve/asset-pipeline/issues/76

The assets under my app/assets are loading perfectly.

I have created a workbench package and I want to add two more directories to the asset pipeline path.

Here's the service provider boot method in the package:

public function boot()
    {
        $count = 1;
        $project_base = $this->app['path.base'];
        $base = realpath(__DIR__ . '/../../../assets');
        $base = str_replace($project_base, '', $base, $count);
        $base = substr($base, 1);

        \Event::listen('asset.pipeline.boot', function($pipeline) use ($base)
        {
            $config = $pipeline->getConfig();

            $config['paths'][] = $base . '/javascrips';
            $config['paths'][] = $base . '/stylesheets';

            $pipeline->setConfig($config);
        });

        $this->package('seckin/desktop');
    }

And when I dump the $config['paths'] after it is set above, it reads correctly:

Array
(
    [0] => app/assets/javascripts
    [1] => app/assets/stylesheets
    [2] => app/assets/images
    [3] => lib/assets/javascripts
    [4] => lib/assets/stylesheets
    [5] => lib/assets/images
    [6] => provider/assets/javascripts
    [7] => provider/assets/stylesheets
    [8] => provider/assets/images
    [9] => workbench/seckin/desktop/assets/javascrips
    [10] => workbench/seckin/desktop/assets/stylesheets
)

However the added items are not loaded when I fire up the app.

Any thoughts?

kloneets commented 10 years ago

I think, you need tu put //= require_tree ../path/to/your/javascripts in assets/javascripts/application.js. But I give no guarantee :D