diff --git a/composer.json b/composer.json index 315aca9..f57ace6 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Admin.php b/src/Admin.php index 9d1bc1a..db4995f 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -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; @@ -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