承接 lucidtaz/yii2-scssphp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lucidtaz/yii2-scssphp

最新稳定版本:0.3.1

Composer 安装命令:

composer require lucidtaz/yii2-scssphp

包简介

Yii2 bindings for scssphp

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage

Yii2 bindings for SCSS-PHP

This library provides easy integration of scssPhp/scssphp into Yii2. Scssphp is a native PHP SCSS (SASS) compiler. This enables you to seamlessly use SCSS while using Yii's method of asset publication.

Usage

Configure web.php to disable Yii's built-in asset converter and use the new one:

<?php

$config = [
    // Other configuration...

    'components' => [
        'assetManager' => [
            'converter' => 'lucidtaz\yii2scssphp\ScssAssetConverter',
        ],

        // Other components...
    ],

    // Other configuration...
];

If the AppAsset is placed in /assets and the scss file in /assets/source/site.scss, your AppAsset.php could look like:

<?php

namespace app\assets;

use yii\web\AssetBundle;

class AppAsset extends AssetBundle
{
    public $sourcePath = '@app/assets/source';
    public $css = [
        'site.scss',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];
}

In other words; you can just use the .scss file(s) in the $css array.

Customizing the SCSS parser

The underlying library, yii2-scssphp, can be customized in case more flexibility is needed. To this end, properties of the ScssPhp\ScssPhp\Compiler object can be overridden in the DI container, as follows:

<?php

$config = [
    // Other configuration...

    'components' => [
        'assetManager' => [
            'converter' => 'lucidtaz\yii2scssphp\ScssAssetConverter',
        ],

        // Other components...
    ],
    'container' => [
        'definitions' => [
            \ScssPhp\ScssPhp\Compiler::class => function () {
                // You can also use a child class here:
                $compiler = new \ScssPhp\ScssPhp\Compiler();
                $compiler->setOutputStyle(\ScssPhp\ScssPhp\OutputStyle::COMPRESSED);

                return $compiler;
            }
        ],
    ],

    // Other configuration...
];

This usage in config.php is supported from Yii 2.0.11. Before that you should use the DI container directly. In that case, please refer to the Yii Dependency Injection readme.

Contributing

When contributing code, please make sure the tests keep passing. Additionally the code is checked by phpstan to detect any statically analyzable issues.

To run these checks, simply execute composer ci.

That being said, please do not hesitate to contribute when the tests fail. If you need assistance in making the build green for your pull request, just let me know in the PR.

统计信息

  • 总下载量: 76.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-29