I’m also noticing this minor issue while developing. But finding changes in imported less files could be a litte bit tough to spot since the only connection WP-LESS has to those files is made via enqueue style to your main file that contains your imports. WP-LESS would need to parse and watch for those imported files separately which seems a bit out of reach to me.
The easiest way to speed up my workflow was to force compile all files on every page call:
<?php
function always_compile_less() {
global $WPLessPlugin;
$WPLessPlugin->processStylesheets( true ); // force compile
}
add_action( 'wp', 'always_compile_less' );
This takes a bit less than a second to compile twitter bootstrap 2.1 on every pageload on my system but should definitely not be enabled on a live system.
Thanks for the tip Jan, good thinking. You’re right, it does seem to be something that can’t be easily addressed in the plugin itself.
I use the WP_LOCAL_DEV constant to signal dev environments (http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/), so this is what I’m doing:
add_action( 'after_setup_theme', 'my_setup' );
function my_setup() {
add_action( 'wp_print_styles', 'my_process_less' );
add_action( 'admin_print_styles', 'my_process_less' );
}
function my_process_less() {
global $WPLessPlugin;
$WPLessPlugin->processStylesheets( WP_LOCAL_DEV );
}
This is great. I was also thinking about a little refinement
function always_compile_less() {
global $WPLessPlugin;
$WPLessPlugin->processStylesheets( true ); // force compile
}
if( WP_DEBUG )
add_action( 'wp', 'always_compile_less' );
to prevent this from running in a live environment.
Happy to see that in the latest version of the plugin less is always compiled when WP_DEBUG is set true. That way you don’t need the code i posted above.
Hi,
Nice to see those technical conversations 🙂
Someone also asked to have an option to force compilation when WP_DEBUG
is set to false. I don’t like very much making the task easy to decrease performances but maybe I’ll add another constant to ease the work if some people need it.