From 334bb596c2690ef0e7c247f6fbc2ec34730d2af4 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 25 Apr 2015 22:34:56 +0930 Subject: [PATCH] Recompile assets every time a file changes --- framework/core/src/Support/AssetManager.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Support/AssetManager.php b/framework/core/src/Support/AssetManager.php index b271ee333..16dd28016 100644 --- a/framework/core/src/Support/AssetManager.php +++ b/framework/core/src/Support/AssetManager.php @@ -79,7 +79,15 @@ class AssetManager $this->putRevision($revision); } - if (! file_exists($file = $dir.'/'.$this->name.'-'.$revision.'.'.$type)) { + $lastModTime = 0; + foreach ($this->files[$type] as $file) { + $lastModTime = max($lastModTime, filemtime($file)); + } + $debug = 0; + + if (! file_exists($file = $dir.'/'.$this->name.'-'.$revision.'.'.$type) + || filemtime($file) < $lastModTime + || $debug) { $this->storage->put($file, $callback()); } @@ -147,7 +155,7 @@ class AssetManager $js = ''; foreach ($this->files['js'] as $file) { - $js .= $this->storage->get($file); + $js .= $this->storage->get($file).';'; } // minify