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

Add less.php as an option in addition to lessphp #119

Closed dwightwatson closed 10 years ago

dwightwatson commented 10 years ago

less.php is a relatively new option for compiling LESS using PHP. Seeing as the existing lessphp is having issues compiling newer versions of Bootstrap, it may be worth adding an option to use less.php as it is said to support newer versions of LESS and Bootstrap. Furthermore, it might be a suitable default replacement for lessphp.

kdocki commented 10 years ago

@dwightwatson Thanks. I've been meaning to try out some new minifiers as the existing ones seem to cause some issues. It would be nice to find a minifier that just throws an exception or something then I might just do this in the AssetPipeline CssMinifierFilter


// $code is the unminified code

try {
  return $minifier->minify($code);
} catch(MinifierException $e) {

}

// failed to minify so just return regular code instead...
return $code;
kdocki commented 10 years ago

Well, I tried that plugin out and it didn't work. So back to the old one.

briankiewel commented 10 years ago

@kdocki What type of issues were you seeing with the new less.php plugin? Not sure if you saw on less.php's readme, but they have an adapter that lets you easily transition from the current package you're using with no additional changes. I tested out just swapping the require value out for the new package in composer.json and it seemed to work fine for me with no additional changes and I can now compile Bootstrap 3.1 with asset-pipeline.

https://github.com/briankiewel/asset-pipeline/commit/bd725df55ea5ed87deea588863655ab0147d4fa6

kdocki commented 10 years ago

@briankiewel I saw that. One of the issues was that it wasn't scoping correctly... so for example if you did @import colors.less it wouldn't find it because it didn't know where to look. So if I setup the importDirs ... it still didn't work. You are welcome to do a pull request if you'd like...

briankiewel commented 10 years ago

@kdocki Weird, the code below is working for me with just the composer.json switch.

@import 'colors-samedir.less';
@import 'subdir/colors-subdir.less';

body {
  color: @base;
}
p {
  color: @foo;
}

I'll definitely submit a PR, just don't want to if I'm missing something that's breaking for others.