This article mainly introduces the YII2 simple use less instead of CSS example, small series feel very good, now share to everyone, also give you a reference. Let's take a look at it with a little knitting.
Adding componentsphp composer.phar require --prefer-dist singrana/yii2-less "*"
Modify config file ' main.php '
' Components ' = [' Assetmanager ' + [' converter ' = ' = ' class ' and ' = ' \singrana\assets\ Converter::classname (),],],
In the AppAsset
Class Appasset extends assetbundle{public $basePath = ' @webroot '; Public $baseUrl = ' @web '; Public $css = [ ' css/site.less ',//*.less replaces the *.CSS and uses the. less suffix in the CSS directory, and ignores. css files in the repository ]; Public $JS = [ ]; Public $depends = [ ' Yii\web\yiiasset ', ' Yii\bootstrap\bootstrapasset ', ];}
So you can write the style with less.