Home  >  Article  >  Backend Development  >  Detailed code example of using less instead of css in yii2

Detailed code example of using less instead of css in yii2

黄舟
黄舟Original
2017-03-10 19:07:481352browse

This article mainly introduces the example of using less to replace css in yii2. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor and take a look.

Add componentsphp composer.phar require --prefer-dist singrana/yii2-less "*"

Modify Configuration file `main.php'

'components' => [
  'assetManager' => [
    'converter' =>
      [
        'class' => \singrana\assets\Converter::className(),
      ],
  ],
],

In AppAsset

class AppAsset extends AssetBundle
{
  public $basePath = '@webroot';
  public $baseUrl = '@web';
  public $css = [
    'css/site.less', //*.less代替*.css并在css目录中使用.less后缀的,并在版本库中忽略.css文件
  ];
  public $js = [
  ];
  public $depends = [
    'yii\web\YiiAsset',
    'yii\bootstrap\BootstrapAsset',
  ];
}

This way you can use less to write styles

The above is the detailed content of Detailed code example of using less instead of css in yii2. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn