Skip to content

Commit

Permalink
allow higher customization for compiling assets
Browse files Browse the repository at this point in the history
  • Loading branch information
luceos committed Sep 26, 2020
1 parent 82af307 commit b363b1a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Frontend/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public function localeCss($callback)
return $this;
}

private function addSources($type, $callback)
protected function addSources($type, $callback)
{
$this->sources[$type][] = $callback;
}

private function populate(CompilerInterface $compiler, string $type, string $locale = null)
protected function populate(CompilerInterface $compiler, string $type, string $locale = null)
{
$compiler->addSources(function (SourceCollector $sources) use ($type, $locale) {
foreach ($this->sources[$type] as $callback) {
Expand All @@ -102,7 +102,7 @@ private function populate(CompilerInterface $compiler, string $type, string $loc

public function makeJs(): JsCompiler
{
$compiler = new JsCompiler($this->assetsDir, $this->name.'.js');
$compiler = $this->makeJsCompiler($this->name.'.js');

$this->populate($compiler, 'js');

Expand All @@ -120,7 +120,7 @@ public function makeCss(): LessCompiler

public function makeLocaleJs(string $locale): JsCompiler
{
$compiler = new JsCompiler($this->assetsDir, $this->name.'-'.$locale.'.js');
$compiler = $this->makeJsCompiler($this->name.'-'.$locale.'.js');

$this->populate($compiler, 'localeJs', $locale);

Expand All @@ -136,6 +136,11 @@ public function makeLocaleCss(string $locale): LessCompiler
return $compiler;
}

protected function makeJsCompiler(string $filename)
{
return new JsCompiler($this->assetsDir, $filename);
}

protected function makeLessCompiler(string $filename): LessCompiler
{
$compiler = new LessCompiler($this->assetsDir, $filename);
Expand Down

0 comments on commit b363b1a

Please sign in to comment.