dev-master
9999999-dev http://www.waga.itAn helper component for styles compiling
GPL-2.0+
by Waga Team
An helper component for styles compiling
An extensible style compiler., (*1)
By now it has a build-in Less compiler, but developers can implement new compilers thanks to Base_Compiler interface., (*2)
//Setup the base compiler: $output_dir = "...." $base_compiler = new WBF\components\compiler\less\Less_Compiler([ "sets" => [ "theme_frontend" => [ "input" => get_stylesheet_directory()."/assets/src/less/input.less", "output" => $output_dir."/output.css", "map" => $output_dir."/output.css.map", "map_url" => $output_uri."/output.css.map", "cache" => get_stylesheet_directory()."/assets/cache", "import_url" => get_stylesheet_directory_uri(), "primary" => true //This is the primary set (by now this is just a label for further usage) ] ], "sources_path" => get_stylesheet_directory()."/assets/src/less/" ]); //Create a new instance of compiler $c = new components\compiler\Styles_Compiler($base_compiler); //This is a wrapper which rely on Base_Compiler implementation of $base_compiler. $c->compile(); //Wraps the call to $base_compiler compile() method
The compile actions is more useful if hooked at some WordPress or user action., (*3)
Base_Compiler provides add_set()
and remove_set()
functions and the compile()
functions allows to specify a set name to compile. So new compilers have to be developed with this concept in mind., (*4)
A set has a name and some properties specified with an array., (*5)
This is, for example, a set valid for Less_Compiler:, (*6)
[ "input" => "...", "output" => "...", "map" => "...", "map_url" => "...", "cache" => "...", "import_url" => "...", "primary" => true ]
The number of properties is arbitrary., (*7)
An helper component for styles compiling
GPL-2.0+