Skip to content

Commit

Permalink
feat: copy sourcemap files after postCSS()
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jan 25, 2023
1 parent f0f04ab commit b925b58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 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.17.1',
'version' => '2.18.0',
'summary' => 'Module for easy frontend development',
'autoload' => true,
'singular' => true,
Expand Down Expand Up @@ -1103,6 +1103,10 @@ public function rfGrow($_data, $shrink = false): string
$grow = "$max - $diff * $percent";
return "clamp($min, $grow, $max)";
} else {
// if scale is one we return a nicer syntax
if ($scale === 1 or $scale === '1') {
return "clamp($min, $min + $diff * $percent, $max)";
}
$grow = "$min * $scale + $diff * $scale * $percent";
return "clamp($min * $scale, $grow, $max * $scale)";
}
Expand Down
9 changes: 9 additions & 0 deletions StylesArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ private function parseLessFiles($opt)

/**
* Add some postCSS magic to css files
*
* We save generated CSS files to /site/assets as it should be writable.
*
*/
public function postCSS($asset)
{
Expand All @@ -159,6 +162,12 @@ public function postCSS($asset)
// asset has been changed, update cached file
$markup = $rf->postCSS($markup);
$rf->writeAsset($newFile, $markup);

// if there is a sourcemap file for the given asset we copy it
// over to the new location
if (is_file($src = $asset->path . ".map")) {
$this->wire->files->copy($src, $newFile . ".map");
}
}
$asset->setPath($newFile);
return $asset;
Expand Down

0 comments on commit b925b58

Please sign in to comment.