Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion AllInOneMinify.module
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ class AllInOneMinify extends WireData implements Module, ConfigurableModule {
$stylesheets = self::_fileArray($stylesheets, array('.css', '.less'));
$cacheFile = self::_getCacheName($stylesheets, self::$cssCachePrefix, '.css');
$assetDomain = self::_getAssetDomain();
$isVirtualHost = $_SERVER['DOCUMENT_ROOT'] !== str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']);

// ------------------------------------------------------------------------
// Check if there is already a combined and cached file. If not,
Expand Down Expand Up @@ -594,14 +595,22 @@ class AllInOneMinify extends WireData implements Module, ConfigurableModule {
// Load source of file and rewrite absolute URLs.
// ------------------------------------------------------------------------
$_css_src = file_get_contents($stylesheet['absolute_path']).PHP_EOL;
$_css_src = (!empty($_css_src)) ? Minify_CSS_UriRewriter::rewrite($_css_src, dirname($stylesheet['absolute_path'])) : $_css_src;
if (!empty($_css_src)) {
$_css_src = Minify_CSS_UriRewriter::rewrite($_css_src, dirname($stylesheet['absolute_path']), $isVirtualHost ? wire('config')->paths->root : null);
}

// ------------------------------------------------------------------------
// If LESS file then run LESS parser.
// ------------------------------------------------------------------------
if($stylesheet['file_extension'] === 'less') {
try {
$_less_parser = new Less_Parser();
if ($isVirtualHost) {
$relativeDirectory = DIRECTORY_SEPARATOR
. str_replace(wire('config')->paths->root, '', dirname($stylesheet['absolute_path']))
. DIRECTORY_SEPARATOR ;
$_less_parser->SetImportDirs([ dirname($stylesheet['absolute_path']) . DIRECTORY_SEPARATOR => $relativeDirectory ] );
}
$_less_parser->parse($_css_src);
$_css_src = $_less_parser->getCss();

Expand Down
Loading