From fbe87416cf4fe7ea0a49c1de039a9d140b34046b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 26 May 2016 22:24:56 +0930 Subject: [PATCH] Don't write/serve empty asset files The new locale-specific CSS file doesn't have any content by default, so it's a waste to write it and serve it to the user. --- framework/core/src/Asset/RevisionCompiler.php | 11 ++++++++--- framework/core/src/Http/WebApp/WebAppView.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Asset/RevisionCompiler.php b/framework/core/src/Asset/RevisionCompiler.php index 31656a7b5..b7d207398 100644 --- a/framework/core/src/Asset/RevisionCompiler.php +++ b/framework/core/src/Asset/RevisionCompiler.php @@ -90,10 +90,15 @@ class RevisionCompiler implements CompilerInterface unlink($file); } - $this->putRevision($current); - $file = $this->path.'/'.substr_replace($this->filename, '-'.$current, -strlen($ext) - 1, 0); - file_put_contents($file, $this->compile()); + + if ($this->files || $this->strings) { + $this->putRevision($current); + + file_put_contents($file, $this->compile()); + } else { + return null; + } } return $file; diff --git a/framework/core/src/Http/WebApp/WebAppView.php b/framework/core/src/Http/WebApp/WebAppView.php index 5020789d9..651f941b7 100644 --- a/framework/core/src/Http/WebApp/WebAppView.php +++ b/framework/core/src/Http/WebApp/WebAppView.php @@ -343,7 +343,7 @@ class WebAppView { return array_map(function ($file) use ($baseUrl) { return $baseUrl.str_replace(public_path(), '', $file); - }, $files); + }, array_filter($files)); } /**