A CURL
wrapper to build TailwindCSS with PHP.
Installed PostCSS plugins:
Installed TailwindCSS plugins:
<?php
// Load
require('tailwindapi.php');
// Init
$tailwind = new TailwindAPI();
// Build
$css = $tailwind->build(); // Return default Tailwind compilation
<?php
$css = $tailwind->build(array(
'css' => false, // Default: Tailwind PostCSS (@tailwind base; @tailwind components; @tailwind utilities;)
'config' => false, // Default: Tailwind Config (module.exports = {theme:{extend:{}},variants:{},plugins:[]})
'autoprefixer' => true, // Default: Autoprefixer enabled
'minify' => true, // Default: Minify enabled
'prefixer' => false, // Default: Prefixer disabled
'output' => false, // Default: Return compiled CSS
));
<?php
$css = $tailwind->build(array(
'css' => '
@tailwind base;
@tailwind components;
.btn{
@apply bg-blue-500 font-bold;
&:hover{
@apply bg-blue-800;
}
}
@tailwind utilities;
',
'config' => '
module.exports = {
theme: {
colors: {
indigo: "#5c6ac4",
blue: "#007ace",
red: "#de3618",
}
}
}
',
));
<?php
$css = $tailwind->build(array(
'css' => 'path/to/postcss-file.css',
'config' => 'path/to/config.js',
));
<?php
$css = $tailwind->build(array(
'prefixer' => '.my-prefix'
));
<?php
$css = $tailwind->build(array(
'prefixer' => array(
'prefix' => '.my-prefix',
'exclude' => array('html')
)
));
<?php
$tailwind->build(array(
'output' => 'path/to/output.css', // PHP needs write permission
));