From 710d2517b8c0ba4ea173e830a72e727abea38e70 Mon Sep 17 00:00:00 2001 From: SamuelNCarvalho Date: Thu, 6 Feb 2020 11:19:52 -0300 Subject: [PATCH] Allow minify compiler to render component alias --- src/Compilers/MinifyCompiler.php | 9 ++++++++- src/HTMLMinServiceProvider.php | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Compilers/MinifyCompiler.php b/src/Compilers/MinifyCompiler.php index 3c441e1..31b7cdd 100644 --- a/src/Compilers/MinifyCompiler.php +++ b/src/Compilers/MinifyCompiler.php @@ -44,15 +44,22 @@ class MinifyCompiler extends BladeCompiler * @param \Illuminate\Filesystem\Filesystem $files * @param string $cachePath * @param array $ignoredPaths + * @param array $customDirectives * * @return void */ - public function __construct(BladeMinifier $blade, Filesystem $files, $cachePath, $ignoredPaths = []) + public function __construct(BladeMinifier $blade, Filesystem $files, $cachePath, $ignoredPaths = [], $customDirectives = []) { parent::__construct($files, $cachePath); $this->blade = $blade; $this->ignoredPaths = $ignoredPaths; $this->compilers[] = 'Minify'; + + if (count($customDirectives)) { + foreach ($customDirectives as $key => $value) { + $this->directive($key, $value); + } + } } /** diff --git a/src/HTMLMinServiceProvider.php b/src/HTMLMinServiceProvider.php index aeee44e..623c253 100644 --- a/src/HTMLMinServiceProvider.php +++ b/src/HTMLMinServiceProvider.php @@ -164,12 +164,13 @@ protected function registerBladeMinifier() protected function registerMinifyCompiler() { $this->app->singleton('htmlmin.compiler', function (Container $app) { + $oldCompiler = $app['blade.compiler']; $blade = $app['htmlmin.blade']; $files = $app['files']; $storagePath = $app->config->get('view.compiled'); $ignoredPaths = $app->config->get('htmlmin.ignore', []); - return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths); + return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $oldCompiler->getCustomDirectives()); }); $this->app->alias('htmlmin.compiler', MinifyCompiler::class);