src/LessCompiler.php
public function processLessFile($file)
    {
        if (!preg_match('/\.less$/', $file)) { // Not a less file
            return $file;
        } elseif (!empty(self::$processed_files[$file])) { // already processed
            return self::$processed_files[$file];
        }

        $less_file = $file;

        // return if not a file
        if (!is_file(Director::getAbsFile($less_file))) {
            self::$processed_files[$file] = $file;
            return $file;
        }

        // Generate a new CSS filename that includes the original path to avoid naming conflicts.
        // eg: themes/site/css/file.less becomes themes-site-css-file.css
        $url_friendly_css_name = $this->file_name_filter->filter(
            str_replace('/', '-', preg_replace('/\.less$/i', '', $less_file))
        ) . '.css';

        $css_file = $this->getCombinedFilesFolder() . '/' . $url_friendly_css_name;

        $output_file = $this->asset_handler->getContentURL($css_file);

        if (is_null($output_file) || $this->is_dev) {
            $cache_dir = self::getCacheDir();

            // relative links in css
            $less_base = dirname(Director::baseURL() . $less_file) . '/';

            // Set less options
            $cache_method = $this->config->get('Axllent\\Less\\LessCompiler', 'cache_method');

            $options = [
                'cache_dir' => $cache_dir,
                'cache_method' => $cache_method,
                'compress' => Director::isLive() // compress CSS if live
            ];

            $current_raw_css = $this->asset_handler->getContent($css_file);

            // Generate and return compiled/cached file path
            $variables = $this->config->get('Axllent\\Less\\LessCompiler', 'variables');

            $cached_file = $cache_dir . '/' . \Less_Cache::Get(
                array(Director::getAbsFile($less_file) => $less_base),
                $options,
                $variables
            );

            if (is_null($output_file) || md5($current_raw_css) != md5_file($cached_file)) {
                $this->asset_handler->setContent($css_file, file_get_contents($cached_file));
            }

            $output_file = $this->asset_handler->getContentURL($css_file);
        }

        $parsed_file = Director::makeRelative($output_file);

        self::$processed_files[$file] = $parsed_file;
        self::$processed_files[$parsed_file] = $parsed_file;

        return $parsed_file;
    }
public function processLessFile($file)
    {
        if (!preg_match('/\.less$/', $file)) { // Not a less file
            return $file;
        } elseif (!empty(self::$processed_files[$file])) { // already processed
            return self::$processed_files[$file];
        }

        $less_file = $file;

        // return if not a file
        if (!is_file(Director::getAbsFile($less_file))) {
            self::$processed_files[$file] = $file;
            return $file;
        }

        // Generate a new CSS filename that includes the original path to avoid naming conflicts.
        // eg: themes/site/css/file.less becomes themes-site-css-file.css
        $url_friendly_css_name = $this->file_name_filter->filter(
            str_replace('/', '-', preg_replace('/\.less$/i', '', $less_file))
        ) . '.css';

        $css_file = $this->getCombinedFilesFolder() . '/' . $url_friendly_css_name;

        $output_file = $this->asset_handler->getContentURL($css_file);

        if (is_null($output_file) || $this->is_dev) {
            $cache_dir = self::getCacheDir();

            // relative links in css
            $less_base = dirname(Director::baseURL() . $less_file) . '/';

            // Set less options
            $cache_method = $this->config->get('Axllent\\Less\\LessCompiler', 'cache_method');

            $options = [
                'cache_dir' => $cache_dir,
                'cache_method' => $cache_method,
                'compress' => Director::isLive() // compress CSS if live
            ];

            $current_raw_css = $this->asset_handler->getContent($css_file);

            // Generate and return compiled/cached file path
            $variables = $this->config->get('Axllent\\Less\\LessCompiler', 'variables');

            $cached_file = $cache_dir . '/' . \Less_Cache::Get(
                array(Director::getAbsFile($less_file) => $less_base),
                $options,
                $variables
            );

            if (is_null($output_file) || md5($current_raw_css) != md5_file($cached_file)) {
                $this->asset_handler->setContent($css_file, file_get_contents($cached_file));
            }

            $output_file = $this->asset_handler->getContentURL($css_file);
        }

        $parsed_file = Director::makeRelative($output_file);

        self::$processed_files[$file] = $parsed_file;
        self::$processed_files[$parsed_file] = $parsed_file;

        return $parsed_file;
    }
Process less file (if detected) and return new URL
@param String (original)
@return String (new filename)