It seems that the problem was that I was adding the function to ‘init’ and where the preview was not updated. Adding it to wp_enqueue_script solved my issue.
Changed
add_action('init', 'autoCompileLess');
to
add_action('wp_enqueue_scripts', 'autoCompileLess');