jdz / less2css
Parse/Compress Less to CSS
2.0.6
2022-01-15 15:00 UTC
Suggests
- mishal/iless: Needed to support the ILess parser ^2.2
- oyejorge/less.php: Needed to support the LessC parser 1.7.0
- websharks/css-minifier: Needed to support the WebSharks minifier 150820
Conflicts
- mishal/iless: <2.2 >2.3
- oyejorge/less.php: <1.7.0 >1.7.0
- websharks/css-minifier: <150820 >150820
README
Use to easily convert your less files to a unique optionally minified css file.
Prepared parser use for :
- ILess by Michal Moravec
- less.php by Josh Schmidt
Prepared minifier for :
- a simple personnal minifier
- css-minifier by WebSharks, Inc.
ILess compresses the CSS by itself so no need for another minifier.
Some upgrades
It needs some enhancements (eg. access parser built in methods and configuration). I built this proxy for my personnal use and needs in the first place.
Basic Usage
$parserImplementation = 'iLess';
// $parserImplementation = 'lessc';
$compressorImplementation = 'simple';
// $compressorImplementation = 'websharks';
use JDZ\Less2Css\Parser\Parser;
use JDZ\Less2Css\Parser\ParserInterface;
use JDZ\Less2Css\Minifier\Minifier;
$parser = \JDZ\Less2Css\Parser\Parser::getInstance($parserImplementation, true);
// parses the file
$parser->parseFile('file1.less');
// parse string
$parser->parseString('body { color: @text-color; }');
// add some variables
$parser->addVariables([
'text-color' => '#222'
]);
$css = $parser->getCSS();
if ( !$parser->isCssCompressed() ){
// compress the css result because the parser did not do it
$minifier = Minifier::getInstance($compressorImplementation, $css);
$css = $minifier->compressCss();
}
echo $css;