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

Less.js (follow-up) #160

Closed vincentcordel closed 10 years ago

vincentcordel commented 10 years ago

Hi there,

I read the following issue: https://github.com/CodeSleeve/asset-pipeline/issues/124

You mentioned to write a wrapper.

So I created the following filter: <?php namespace Codesleeve\AssetPipeline\Filters;

use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;

class LessjsFilter extends \Assetic\Filter\LessjsFilter
{

}

And in the config file, I changed the less filter to:

'.less' => array(
new Codesleeve\AssetPipeline\Filters\LessjsFilter,
new Codesleeve\AssetPipeline\Filters\URLRewrite(App::make('url')->to('/')),
new EnvironmentFilter(new Codesleeve\AssetPipeline\Filters\CssMinFilter, App::environment()),
),

However this doesn't work yet. I can't create a file in the vendor folder so the path is obviously incorrect.

My question:

Thanks again and sorry for the easy question :)

kdocki commented 10 years ago

where should I put the wrapper?

you can put the wrapper any where you want so long as that Class is available at runtime. you don't have to namespace it under Codesleeve\AssetPipeline\Filters either. if you open up your composer.json you can add the file manually if you want to...

  "autoload": {
      "files": [
           "app\libs\LessjsFilter.php"
       ]
     }

how do I reference the file in the config file?

Not sure what "file" you mean here. Are you talking about the LessjsFilter.php file you created? You will not need to reference (or require "Some\Path\LessjsFilter.php") so long as composer is autoloading this class.

am I missing something to make it work?

I don't see anything wrong with this right off the bat. You might use a different namespace since this is your custom filter.