LessPHP, Basset & Laravel - strange parse error

293 Views Asked by At

I'm having a lot of difficulty getting LESS parsing to work nicely in Laravel. I did some Googling and found Basset which seems to support LESS, and then found that it doesn't actually parse LESS. So I installed LessPHP as well to do the parsing.

Now when I try to use the world's simplest LESS file:

@red: #f00;

body {
    background-color: @red;
}

It doesn't work. I get a "parse error":

ErrorException
parse error: failed at `@red: #f00; ` line: 1

Does anyone know what incredibly obvious mistake I've made here?

What I've done so far:

  1. Downloaded and installed Laravel
  2. Added "jasonlewis/basset": "dev-master" and "leafo/lessphp": "dev-master" to composer.json
  3. Run a composer update
  4. Run a php artisan config:publish jasonlewis/basset
  5. Edited the basset config to point to the LessphpFilter
  6. Edited the vendor/jasonlewis/basset/src/Basset/Asset.php to fix a bug in compatibility with Laravel 4.1
  7. Cleared application cache with php artisan cache:clear
  8. Tried to load the page with the above LESS code
1

There are 1 best solutions below

1
On

There's a work-around for this. If you add a dummy rule to the top of the file like so:

a {}

@red: #f00;

body {
    background-color: @red;
}

It works.