From 404671a623e955f0eb593eb7436fa24dceef2bce Mon Sep 17 00:00:00 2001 From: Marco Hillger Date: Fri, 3 Feb 2017 18:42:37 +0100 Subject: [PATCH 1/4] allow multiple manifest files for mix helper --- src/Illuminate/Foundation/helpers.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index b07dd8800777..c915567afe27 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -552,38 +552,42 @@ function method_field($method) /** * Get the path to a versioned Mix file. * - * @param string $path + * @param string $path + * @param string $manifestDir * @return \Illuminate\Support\HtmlString * * @throws \Exception */ - function mix($path) + function mix($path, $manifestDir = '') { static $manifest; - static $shouldHotReload; - if (! $manifest) { - if (! file_exists($manifestPath = public_path('mix-manifest.json'))) { + if ( $manifestDir && ! starts_with($manifestDir, '/')) { + $manifestDir = "/{$manifestDir}"; + } + + if ( ! $manifest) { + if ( ! file_exists($manifestPath = public_path($manifestDir . '/mix-manifest.json'))) { throw new Exception('The Mix manifest does not exist.'); } $manifest = json_decode(file_get_contents($manifestPath), true); } - if (! starts_with($path, '/')) { + if ( ! starts_with($path, '/')) { $path = "/{$path}"; } - if (! array_key_exists($path, $manifest)) { + if ( ! array_key_exists($path, $manifest)) { throw new Exception( - "Unable to locate Mix file: {$path}. Please check your ". + "Unable to locate Mix file: {$path}. Please check your " . 'webpack.mix.js output paths and try again.' ); } - return $shouldHotReload = file_exists(public_path('hot')) - ? new HtmlString("http://localhost:8080{$manifest[$path]}") - : new HtmlString($manifest[$path]); + return file_exists(public_path($manifestDir . '/hot')) + ? new HtmlString("http://localhost:8080{$manifest[$path]}") + : new HtmlString($manifestDir . $manifest[$path]); } } From 029ddc750a1e170f17402edfb0d1a1b91be23e4f Mon Sep 17 00:00:00 2001 From: Marco Hillger Date: Sat, 4 Feb 2017 00:13:52 +0100 Subject: [PATCH 2/4] fixed cs --- src/Illuminate/Foundation/helpers.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index c915567afe27..bb36e28a9874 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -562,32 +562,32 @@ function mix($path, $manifestDir = '') { static $manifest; - if ( $manifestDir && ! starts_with($manifestDir, '/')) { + if ($manifestDir && ! starts_with($manifestDir, '/')) { $manifestDir = "/{$manifestDir}"; } - if ( ! $manifest) { - if ( ! file_exists($manifestPath = public_path($manifestDir . '/mix-manifest.json'))) { + if (! $manifest) { + if (! file_exists($manifestPath = public_path($manifestDir.'/mix-manifest.json'))) { throw new Exception('The Mix manifest does not exist.'); } $manifest = json_decode(file_get_contents($manifestPath), true); } - if ( ! starts_with($path, '/')) { + if (! starts_with($path, '/')) { $path = "/{$path}"; } - if ( ! array_key_exists($path, $manifest)) { + if (! array_key_exists($path, $manifest)) { throw new Exception( - "Unable to locate Mix file: {$path}. Please check your " . + "Unable to locate Mix file: {$path}. Please check your ". 'webpack.mix.js output paths and try again.' ); } - return file_exists(public_path($manifestDir . '/hot')) + return file_exists(public_path($manifestDir.'/hot')) ? new HtmlString("http://localhost:8080{$manifest[$path]}") - : new HtmlString($manifestDir . $manifest[$path]); + : new HtmlString($manifestDir.$manifest[$path]); } } From 7c8bdd8c265489da8cbae6da4bacccf256aeddfe Mon Sep 17 00:00:00 2001 From: Marco Hillger Date: Sat, 4 Feb 2017 00:23:08 +0100 Subject: [PATCH 3/4] fixed cs --- src/Illuminate/Foundation/helpers.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index bb36e28a9874..a0e6fca2fcea 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -552,8 +552,8 @@ function method_field($method) /** * Get the path to a versioned Mix file. * - * @param string $path - * @param string $manifestDir + * @param string $path + * @param string $manifestDir * @return \Illuminate\Support\HtmlString * * @throws \Exception @@ -586,8 +586,8 @@ function mix($path, $manifestDir = '') } return file_exists(public_path($manifestDir.'/hot')) - ? new HtmlString("http://localhost:8080{$manifest[$path]}") - : new HtmlString($manifestDir.$manifest[$path]); + ? new HtmlString("http://localhost:8080{$manifest[$path]}") + : new HtmlString($manifestDir.$manifest[$path]); } } From 8dd5892e32c5f84928bb6322e0dcab1b89fcff09 Mon Sep 17 00:00:00 2001 From: Marco Hillger Date: Sat, 4 Feb 2017 01:27:30 +0100 Subject: [PATCH 4/4] fixes cs --- src/Illuminate/Foundation/helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index a0e6fca2fcea..b8f87c492538 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -552,8 +552,8 @@ function method_field($method) /** * Get the path to a versioned Mix file. * - * @param string $path - * @param string $manifestDir + * @param string $path + * @param string $manifestDir * @return \Illuminate\Support\HtmlString * * @throws \Exception