lucidtaz/yii2-scssphp
Composer 安装命令:
composer require lucidtaz/yii2-scssphp
包简介
Yii2 bindings for scssphp
README 文档
README
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.
lucidtaz/yii2-scssphp 适用场景与选型建议
lucidtaz/yii2-scssphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.11k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2016 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lucidtaz/yii2-scssphp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lucidtaz/yii2-scssphp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 80.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-29