Skip to content

Commit

Permalink
feat: add support to directly minify a less file with $rm->minify(...)
Browse files Browse the repository at this point in the history
Usage:
rockmigrations()->minify(
  __DIR__ . '/src/Foo.less',
  __DIR__ . '/dst/Foo.min.css'
);
  • Loading branch information
BernhardBaumrock committed Jan 6, 2025
1 parent 45601c9 commit cd036c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,7 @@ public function minify($file, $minFile = null): string|false
try {
$minify->minify($minFile);
} catch (\Throwable $th) {
if (wire()->config->debug) $this->log($th->getMessage());
}
$this->log("Minified $minFile");
} elseif ($ext == 'js') {
Expand All @@ -3569,7 +3570,13 @@ public function minify($file, $minFile = null): string|false
try {
$minify->minify($minFile);
} catch (\Throwable $th) {
if (wire()->config->debug) $this->log($th->getMessage());
}
} else if ($ext == 'less') {
// less files will be converted to css with default settings
// if you want to customise that you can use saveCSS() in your code
$css = $this->saveCSS($file);
return $this->minify($css, $minFile);
} else {
throw new WireException("Invalid Extension $ext");
}
Expand Down

0 comments on commit cd036c4

Please sign in to comment.