oyejorge / less.php

less.js ported to PHP.
http://lessphp.typesettercms.com
Apache License 2.0
657 stars 2 forks source link

Less_Cache should take options into account #350

Open Svish opened 6 years ago

Svish commented 6 years ago

When I change options (like 'compress' => true / false), the Less_Cache::get doesn't seem to care and just reuses its cache. 😕

This is a bit annoying, especially for me who's trying to figure out how to use this thing. 😛

Would it be possible for the Less_Cache::get method to also take into account its given options when deciding if it needs to re-compile?

kylekatarnls commented 6 years ago

Hi, I consider this feature in my fork, could you try to require kylekatarnls/less.php instead of oyejorge/less.php and tell me if it works for you?

Thanks.

Svish commented 6 years ago

Replaced Cache.php with yours, and... doesn't seem to do anything for this?

Looking at the diff though, and your change looks to be inside an if (!empty($modify_vars)), and as I'm not modifying any vars at all, that probably explains why. Think the adjustment needs to be done somewhere else?

How I call the method:

File::mkdir(self::CACHE);
$this->_css = self::CACHE . Lessc::Get([ $this->_less => WEBROOT ],
    [
        'compress' => true,
        'strictMath' => true,
        'cache_dir' => self::CACHE,
        'indentation' => "\t",
        'import_callback' => [$this, 'find_import'],
    ]);

Tested it by toggling compress on and off, and the output gets "stuck" on one until I either delete the cache (obviously) or touch one of the less files.

kylekatarnls commented 6 years ago

OK, understood the point. I will inspect that. You should be able to work-around this meanwhile by passing the compress value also in your less variables.

kylekatarnls commented 6 years ago

Sorry I broke something, now I enable TravisCI to avoid such regression, please try with this version: https://github.com/kylekatarnls/less.php/releases/tag/v1.7.0.17