Skip to content

Commit

Permalink
If minifier exist use it for JS.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Jan 6, 2021
1 parent 888acc6 commit 63377e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"nette/caching": "^3.0"
},
"require-dev": {
"baraja-core/assets-loader": "^1.3",
"phpstan/phpstan": "^0.12.18",
"tracy/tracy": "^2.7",
"phpstan/phpstan-nette": "^0.12.6",
Expand Down
8 changes: 7 additions & 1 deletion src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


use Baraja\AdminBar\AdminBar;
use Baraja\AssetsLoader\Minifier\DefaultJsMinifier;
use Baraja\Cms\Plugin\ErrorPlugin;
use Baraja\Cms\Proxy\Proxy;
use Baraja\Cms\User\AdminBarUser;
Expand Down Expand Up @@ -80,10 +81,15 @@ public function run(?string $locale, string $path): void
header('Content-Type: ' . Proxy::CONTENT_TYPES[$assetType]);
$assetContent = file_get_contents(__DIR__ . '/../template/assets/core.' . $assetType)
. (($customAssetPath = $this->context->getCustomAssetPath($assetType)) !== null ? "\n\n" . file_get_contents($customAssetPath) : '');
if ($assetType === 'css') {
$assetContent = Helpers::minifyHtml($assetContent);
} elseif ($assetType === 'js' && \class_exists(DefaultJsMinifier::class)) {
$assetContent = (new DefaultJsMinifier)->minify($assetContent);
}
echo '/*' . "\n"
. ' * This file is part of Baraja CMS.' . "\n"
. ' */' . "\n\n"
. ($assetType === 'css' ? Helpers::minifyHtml($assetContent) : $assetContent);
. $assetContent;
die;
}
if (strncmp($path, 'cms/', 4) !== 0 && $this->context->getUser()->isLoggedIn() === false) { // route login form
Expand Down

0 comments on commit 63377e5

Please sign in to comment.