This is a fork of assetic-autoprefixer.
All credits goes to assetic-autoprefixer.
The original assetic-autoprefixer implements only the autoprefixer postcss module.
This fork adds a cssnext filter for the PHP assetic framework. The project is called Postcss as it could implement each postcss module and let you choose which one to use. As I am new with postcss I am starting with cssnext which is made of (many postcss modules)[http://cssnext.io/usage/] (including autoprefixed) and make it a good start.
kriswallsmith/assetic
is required to be installed in your php project.
postcss/cssnext
is required to be installed on your system.
php composer.phar require kriswallsmith/assetic ~1.0
sudo npm install -g cssnext
npm install cssnext
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');
This project comes with a assetic filter configuration file, located in the config
directory.
Define the cssnext binary path in the parameters.yml
:
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
Then enable the filter in the assetic
configuration chapter:
# 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"