Detailed code example of using less instead of css in yii2

黄舟
Release: 2023-03-06 14:02:02
Original
1347 people have browsed it

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(),
      ],
  ],
],
Copy after login

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',
  ];
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template