jasonlewis / basset

A better asset management package for Laravel.
http://jasonlewis.me/code/basset
240 stars 76 forks source link

Problem using leafo/scssphp #214

Closed jsvensson closed 1 year ago

jsvensson commented 11 years ago

Not quite sure which tree to bark up, but I'll try here.

This project is hosted on Pagoda, meaning it needs to be pure PHP -- no Ruby available for sass, so I'm using leafo/scssphp (dev-master version) as recommended instead.

It doesn't do the SASS syntax, just SCSS, so I split the default filter into two:

'Sass' => array('Sass\SassFilter', function($filter)
{
  $filter->whenAssetIs('.*\.sass')->findMissingConstructorArgs();
}),

'Scss' => array('Sass\ScssphpFilter', function($filter)
{
  $filter->whenAssetIs('.*\.scss')->findMissingConstructorArgs();
}),

The app collection:

$directory = $collection->directory('assets/stylesheets', function($collection)
{
  $collection->requireDirectory('scss')->apply('Scss');
  $collection->requireDirectory();
});

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

The problem: it just passes the raw SCSS file straight through, without compiling, so I end up with a new CSS file that just contains the raw SCSS. On the first page view after a change to the .scss file I also get an error about the filter name. This goes away after the first page view.

LOG.error: "Sass\ScssphpFilter" will not be applied to asset "assets/stylesheets/scss/screen.scss" due to an invalid filter name.

Is there something glaringly obvious I'm missing here?

jsvensson commented 11 years ago

Took another quick stab at this. A test that calls ScssPHP directly works as intended:

public function getScssphp()
{
  $path = public_path() . '/assets/stylesheets/scss';
  $s = new scssc();
  $s->setImportPaths($path);
  $css = $s->compile('@import "screen.scss"');

  return View::make('test.scssphp')->with('css', $css);
}

I'll dig deeper when I have the time.

edit: did another test using Assetic's factory manager. That worked as intended too.