mirror of
https://github.com/flarum/core.git
synced 2025-10-12 15:34:26 +02:00
Minify each JS file individually, caching the result
This means that the expensive minification process will only be run for a file if it hasn't before. Greatly speeds up extension enabling/disabling. Also: - Don't check file last modification times in production for a bit of extra perf. - Only flush CSS when theme settings are changed. This speeds up the page reload a bit.
This commit is contained in:
@@ -71,7 +71,7 @@ class AdminServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
$this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) {
|
||||
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
|
||||
$this->flushAssets();
|
||||
$this->getClientController()->flushCss();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -86,7 +86,14 @@ class AdminServiceProvider extends AbstractServiceProvider
|
||||
|
||||
public function flushAssets()
|
||||
{
|
||||
$action = $this->app->make('Flarum\Admin\Controller\ClientController');
|
||||
$action->flushAssets();
|
||||
$this->getClientController()->flushAssets();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Flarum\Admin\Controller\ClientController
|
||||
*/
|
||||
protected function getClientController()
|
||||
{
|
||||
return $this->app->make('Flarum\Admin\Controller\ClientController');
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Flarum\Admin\Controller;
|
||||
use Flarum\Foundation\Application;
|
||||
use Flarum\Http\Controller\AbstractClientController as BaseClientController;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Flarum\Core\Permission;
|
||||
@@ -47,9 +48,10 @@ class ClientController extends BaseClientController
|
||||
LocaleManager $locales,
|
||||
SettingsRepository $settings,
|
||||
Dispatcher $events,
|
||||
Repository $cache,
|
||||
ExtensionManager $extensions
|
||||
) {
|
||||
BaseClientController::__construct($app, $apiClient, $locales, $settings, $events);
|
||||
BaseClientController::__construct($app, $apiClient, $locales, $settings, $events, $cache);
|
||||
|
||||
$this->layout = __DIR__.'/../../../views/admin.blade.php';
|
||||
$this->extensions = $extensions;
|
||||
|
Reference in New Issue
Block a user