From be7ea2b4464edd3ae600488999b98dc6a141dd89 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Wed, 18 Mar 2020 00:07:16 +1300 Subject: [PATCH 01/13] Added the ability to set dev server build type + Build type is either `modern`, `legacy` or `combined`. + Defaults to `modern` to ensure backwards compatibility. --- src/config.php | 2 ++ src/helpers/Manifest.php | 5 +++-- src/models/Settings.php | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/config.php b/src/config.php index 8707191..51fb930 100644 --- a/src/config.php +++ b/src/config.php @@ -49,6 +49,8 @@ 'manifestPath' => 'http://localhost:8080/', 'publicPath' => 'http://localhost:8080/', ], + // Bundle to use with the webpack-dev-server + 'devServerBuildType' => 'modern', // Local files config 'localFiles' => [ 'basePath' => '@webroot/', diff --git a/src/helpers/Manifest.php b/src/helpers/Manifest.php index 5741902..1de28b0 100644 --- a/src/helpers/Manifest.php +++ b/src/helpers/Manifest.php @@ -333,10 +333,11 @@ public static function getManifestFile(array $config, string $type = 'modern') $manifestPath = self::$isHot ? $config['devServer']['manifestPath'] : $config['server']['manifestPath']; - // If this is a dev-server, only look for the modern manifest + // If this is a dev-server, use the defined build type $thisType = $type; + $devServerBuildType = $config['devServerBuildType']; if (self::$isHot) { - $thisType = 'modern'; + $thisType = ($devServerBuildType === 'combined' ? $thisType : $devServerBuildType); } // Normalize the path $path = self::combinePaths($manifestPath, $config['manifest'][$thisType]); diff --git a/src/models/Settings.php b/src/models/Settings.php index 794dad5..d527c92 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -33,7 +33,7 @@ class Settings extends Model * @var bool If true, enforces Absolute Urls, if false, allows relative */ public $useAbsoluteUrl = true; - + /** * @var string The JavaScript entry from the manifest.json to inject on * Twig error pages @@ -69,6 +69,12 @@ class Settings extends Model 'publicPath' => 'http://localhost:8080/', ]; + /** + * @var string defines which bundle will be used from the webpack dev server. + * Can be 'modern', 'legacy' or 'combined'. Defaults to 'modern'. + */ + public $devServerBuildType = 'modern'; + /** * @var array Local files config */ From 8eb83907e85f148cffa58c8edb8a5a01cc8019a2 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Wed, 18 Mar 2020 00:13:56 +1300 Subject: [PATCH 02/13] Updated CHANGELOG and versioned to 1.3.0. --- CHANGELOG.md | 4 ++++ composer.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 720cd5e..4783cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Twigpack Changelog +## 1.3.0 - 2020-03-18 +### Added +* Added the config setting `devServerBuildType` to determine which webpack-dev-server bundle is loaded. + ## 1.2.0 - 2020-02-28 ### Changed * Switched over to using `media="print"` for asynchronously loading a stylesheet as per [The Simplest Way to Load CSS Asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/) diff --git a/composer.json b/composer.json index 37bab69..a255f9c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nystudio107/craft-twigpack", "description": "Twigpack is a bridge between Twig and webpack, with manifest.json & webpack-dev-server HMR support", "type": "craft-plugin", - "version": "1.2.0", + "version": "1.3.0", "keywords": [ "craftcms", "craft-plugin", From bafe551b1eec2818e60c6a67affa4ad0b6979d75 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Wed, 18 Mar 2020 00:29:15 +1300 Subject: [PATCH 03/13] Code formatting --- src/helpers/Manifest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/Manifest.php b/src/helpers/Manifest.php index 1de28b0..34d0527 100644 --- a/src/helpers/Manifest.php +++ b/src/helpers/Manifest.php @@ -335,9 +335,10 @@ public static function getManifestFile(array $config, string $type = 'modern') : $config['server']['manifestPath']; // If this is a dev-server, use the defined build type $thisType = $type; - $devServerBuildType = $config['devServerBuildType']; if (self::$isHot) { - $thisType = ($devServerBuildType === 'combined' ? $thisType : $devServerBuildType); + $thisType = $config['devServerBuildType'] === 'combined' + ? $thisType + : $config['devServerBuildType']; } // Normalize the path $path = self::combinePaths($manifestPath, $config['manifest'][$thisType]); From 8c364cea0671ba6ec9e7eb85394499f521707b3d Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 18 Mar 2020 16:12:04 -0400 Subject: [PATCH 04/13] Fix typo --- docs/docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/README.md b/docs/docs/README.md index 33cf71d..6b9570d 100644 --- a/docs/docs/README.md +++ b/docs/docs/README.md @@ -36,7 +36,7 @@ Twigpack is a bridge between Twig and webpack, with `manifest.json` & [webpack-d Twigpack also handles generating the necessary `