LESS CSS module for Silverstripe using lessphp
MIT License
A wrapper for less.php to integrate LESS into Silverstripe.
?flush
) to regenerate CSS stylesheets (ie. force undetected less changes with @import)assets/_css
and automatically modifies Requirements
pathslive
mode (may require an initial ?flush
)composer require axllent/silverstripe-less
You need refer to your less files by their full LESS filenames (eg:stylesheet.less
).
Note: The less.php
compiler transforms relative paths like url('../images/logo.png')
into url('/themes/site/images/logo.png')
based on the path provided as you included the files, meaning these won't work in Silverstripe due to the exposed directory structure via (_resources/...
). The two simplest solutions are:
Requirements:css('_resources/themes/site/css/stylesheet.less');
In your page controller:
<?php
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\View\Requirements;
class PageController extends ContentController
{
public function init()
{
parent::init();
Requirements:css('themes/site/css/stylesheet.less');
}
}
Or via template
<% require themedCSS("layout.less") %>
The generated HTML will point automatically to the processed CSS file in assets/_css
rather than the original less file location, for example
<link rel="stylesheet" type="text/css" href="/assets/_css/themes-site-css-stylesheet.css?m=123456789" />