Skip to content

Commit b23349b

Browse files
committed
Avoid resolving view when retrieving the previous compiler (Resolves #162).
1 parent 678b959 commit b23349b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/HTMLMinServiceProvider.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
*/
3131
class HTMLMinServiceProvider extends ServiceProvider
3232
{
33+
/**
34+
* @var \Illuminate\View\Compilers\CompilerInterface|null
35+
*/
36+
protected $previousCompiler;
37+
3338
/**
3439
* Boot the service provider.
3540
*
@@ -164,18 +169,22 @@ protected function registerBladeMinifier()
164169
*/
165170
protected function registerMinifyCompiler()
166171
{
167-
$previousCompiler = $this->app->make('view')
168-
->getEngineResolver()
169-
->resolve('blade')
170-
->getCompiler();
172+
if (method_exists($this, 'callAfterResolving')) {
173+
$this->callAfterResolving('view', function () {
174+
$this->previousCompiler = $this->app->make('view')
175+
->getEngineResolver()
176+
->resolve('blade')
177+
->getCompiler();
178+
});
179+
}
171180

172-
$this->app->singleton('htmlmin.compiler', function (Container $app) use ($previousCompiler) {
181+
$this->app->singleton('htmlmin.compiler', function (Container $app) {
173182
$blade = $app['htmlmin.blade'];
174183
$files = $app['files'];
175184
$storagePath = $app->config->get('view.compiled');
176185
$ignoredPaths = $app->config->get('htmlmin.ignore', []);
177186

178-
return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $previousCompiler);
187+
return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler);
179188
});
180189

181190
$this->app->alias('htmlmin.compiler', MinifyCompiler::class);

0 commit comments

Comments
 (0)