asset_compress icon indicating copy to clipboard operation
asset_compress copied to clipboard

less 2.2.0

Open mhorvath opened this issue 10 years ago • 2 comments

is there any plan to update the LessCss.php commands to Less 2.2.0?

mhorvath avatar Jan 12 '15 14:01 mhorvath

We'd need to keep both less1 and less2, so it sounds like another filter would be needed.

markstory avatar Jan 12 '15 16:01 markstory

Hi,

I'm just having a crack at this with Lessc 2.7.1, the existing LessCss.php filter just needs this _generateScript updated to use the new syntax.

I'm still using a LessPHP version which needs more ../ on includes, 3 to be exact. And Lessc doesn't want them, so this keeps the LESS compatible

$input = str_replace('../../../', '', $input);


protected function _generateScript($file, $input) {

        //remove 3 ../ from here
        //..\/..\/..\/..\/..\/   -> ..\/..\/
        $input = str_replace('../../../', '',  $input);

        $text = <<<JS
var less = require('less'),
    util = require('util');

 var options = { paths: %s };
 var lessInput = %s;  //actual LESS code

less.render(lessInput, options)
    .then(function(output) {
            // output.css = string of css
            // output.map = string of sourcemap
            // output.imports = array of string filenames of the imports referenced

            util.print(output.css);
            process.exit(0);
        },
        function(error) {
            less.writeError(error);
            process.exit(1)
        });

JS;
        file_put_contents($file, sprintf($text, str_replace('\/*', '', json_encode($this->_settings['paths'])), json_encode($input)));
    }

mrthan avatar May 11 '16 11:05 mrthan