Skip to content

Commit

Permalink
feat: make it possible to define the output directory for css
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Feb 12, 2023
1 parent 1d3c0e5 commit cf7afd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static function getModuleInfo()
{
return [
'title' => 'RockFrontend',
'version' => '2.21.0',
'version' => '2.22.0',
'summary' => 'Module for easy frontend development',
'autoload' => true,
'singular' => true,
Expand Down Expand Up @@ -960,6 +960,7 @@ public static function html($str)
// string instead. That means if called from outside a latte file it will
// still return the HTML.
try {
require_once __DIR__ . "/vendor/autoload.php";
return new Html($str);
} catch (\Throwable $th) {
return $str;
Expand Down Expand Up @@ -1681,11 +1682,12 @@ public function scriptTag($path, $cacheBuster = false)
*
* @return StylesArray
*/
public function styles($name = 'head')
public function styles($name = 'head', $cssDir = null)
{
if (!$this->styles) $this->styles = new WireData();
$style = $this->styles->get($name) ?: new StylesArray($name);
if ($name) $this->styles->set($name, $style);
if ($cssDir) $style->cssDir = $cssDir;
return $style;
}

Expand Down
3 changes: 2 additions & 1 deletion StylesArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class StylesArray extends AssetsArray
const cacheName = 'rockfrontend-stylesarray-cache';
const comment = '<!-- rockfrontend-styles-head -->';

public $cssDir = false;
protected $vars = [];

/**
Expand Down Expand Up @@ -185,7 +186,7 @@ public function render($options = [])
$opt->setArray([
'debug' => $this->wire->config->debug,
'indent' => ' ',
'cssDir' => "/site/templates/bundle/",
'cssDir' => $this->cssDir ?: "/site/templates/bundle/",
'cssName' => $this->name,
'sourcemaps' => $this->wire->config->debug,
]);
Expand Down

0 comments on commit cf7afd1

Please sign in to comment.