finchen / assetic-postcss
此包已被废弃且不再维护。未建议替代包。
用于 kriswallsmith/assetic 的 postcss 过滤器
dev-master / 1.0.x-dev
2015-12-18 14:41 UTC
Requires
- php: >=5.3
- kriswallsmith/assetic: 1.*
Requires (Dev)
- phpmd/phpmd: ~2.0
- phpunit/phpunit: ~3.7
- squizlabs/php_codesniffer: ~1.0
Replaces
- bit3/assetic-postcss: dev-master
This package is not auto-updated.
Last update: 2018-05-15 02:20:20 UTC
README
这是 assetic-autoprefixer 的分支。
所有荣誉归 assetic-autoprefixer。
原始的 assetic-autoprefixer 仅实现了 autoprefixer postcss 模块。
此分支为 PHP assetic 框架 添加了一个 cssnext 过滤器。由于它可以实现每个 postcss 模块并允许您选择使用哪个,因此项目被称为 Postcss。由于我对 postcss 比较新手,所以我从 cssnext 开始,它由(许多 postcss 模块)http://cssnext.io/usage/ 组成,这是一个很好的起点。
要求
kriswallsmith/assetic
需要在您的 PHP 项目中安装。postcss/cssnext
需要在您的系统上安装。
使用 Composer 安装 kriswallsmith/assetic
php composer.phar require kriswallsmith/assetic ~1.0
在您的系统上全局安装 cssnext
sudo npm install -g cssnext
在您的系统上本地安装 cssnext
npm install cssnext
在 PHP 中的使用
use Bit3\Assetic\Filter\Postcss\CssnextFilter; // if you have installed cssnext globally $cssnextBinary = '/usr/bin/cssnext'; // if you have installed cssnext locally $cssnextBinary = '/../node_modules/.bin/cssnext'; $cssnextFilter = new CssnextFilter($cssnextBinary); // if node.js binary is not installed as /usr/bin/node // (e.g. on debian/ubuntu the binary is named /usr/bin/nodejs) $cssnextFilter->setNodeBin('/usr/bin/nodejs');
在 Symfony2 中的使用
该项目附带一个资产过滤器配置文件,位于 config
目录中。
在 parameters.yml
中定义 cssnext 二进制路径
parameters: # if you have installed cssnext globally assetic.cssnext.bin: /usr/bin/cssnext # if you have installed cssnext locally assetic.cssnext.bin: %kernel.root_dir%/../node_modules/.bin/cssnext # if node.js binary is not installed as /usr/bin/node # (e.g. on debian/ubuntu the binary is named /usr/bin/nodejs) assetic.node.bin: /usr/bin/nodejs
然后,在 assetic
配置章节中启用过滤器
# Assetic Configuration assetic: filters: cssnext: resource: "%kernel.root_dir%/../vendor/netzmacht/assetic-postcss/config/cssnext.xml" # if you like, you can use apply_to here :-) # e.g, apply_to: "\.css" # otherwise you use the filter in your template with filter="cssnext"