From 5295f418ae5bc7cb3a074434db96501b312f9975 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 17:45:26 +0100 Subject: [PATCH 01/21] Add configurable feature to load styles from the TailwindCSS Play CDN --- config/hyde.php | 3 +++ packages/framework/config/hyde.php | 3 +++ .../framework/resources/views/layouts/styles.blade.php | 6 ++++-- .../tests/Unit/Views/StylesComponentViewTest.php | 9 ++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index 08ffd8f946a..c41c689c967 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -190,4 +190,7 @@ */ 'load_app_styles_from_cdn' => false, + + // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. + 'use_play_cdn' => false, ]; diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index 08ffd8f946a..c41c689c967 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -190,4 +190,7 @@ */ 'load_app_styles_from_cdn' => false, + + // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. + 'use_play_cdn' => false, ]; diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 379c18af910..14adf0ff4be 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -2,11 +2,13 @@ {{-- The compiled Tailwind/App styles --}} -@if(config('hyde.load_app_styles_from_cdn', false)) +@if(config('hyde.use_play_cdn', false)) + +@elseif(config('hyde.load_app_styles_from_cdn', false)) @elseif(Asset::hasMediaFile('app.css')) @endif {{-- Add any extra styles to include after the others --}} -@stack('styles') \ No newline at end of file +@stack('styles') diff --git a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php index 7d3db097891..ea16a158ca6 100644 --- a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php +++ b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php @@ -8,6 +8,7 @@ use Hyde\Hyde; use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Blade; +use function config; /** * @see resources/views/layouts/styles.blade.php @@ -63,12 +64,18 @@ public function test_styles_can_be_pushed_to_the_component_styles_stack() @push("styles") foo bar @endpush - + @include("hyde::layouts.styles")' ) ); } + public function test_component_renders_tailwind_play_cdn_link_when_enabled_in_config() + { + config(['hyde.use_play_cdn' => true]); + $this->assertStringContainsString('', $this->renderTestView()); + } + public function test_component_renders_app_cdn_link_when_enabled_in_config() { config(['hyde.load_app_styles_from_cdn' => true]); From a6e4d468bf2efae18fe55920935fb2752e0fced2 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 22 Nov 2022 16:45:41 +0000 Subject: [PATCH 02/21] Apply fixes from StyleCI --- packages/framework/tests/Unit/Views/StylesComponentViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php index ea16a158ca6..4ecb8553b63 100644 --- a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php +++ b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php @@ -4,11 +4,11 @@ namespace Hyde\Framework\Testing\Unit\Views; +use function config; use Hyde\Facades\Asset; use Hyde\Hyde; use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Blade; -use function config; /** * @see resources/views/layouts/styles.blade.php From dc697cfb5e006af4cb919add767ee9e8327be0a5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 17:50:46 +0100 Subject: [PATCH 03/21] Add typography plugin to PlayCDN --- packages/framework/resources/views/layouts/styles.blade.php | 2 +- packages/framework/tests/Unit/Views/StylesComponentViewTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 14adf0ff4be..92724a7bc77 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -3,7 +3,7 @@ {{-- The compiled Tailwind/App styles --}} @if(config('hyde.use_play_cdn', false)) - + @elseif(config('hyde.load_app_styles_from_cdn', false)) @elseif(Asset::hasMediaFile('app.css')) diff --git a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php index 4ecb8553b63..ec69173943e 100644 --- a/packages/framework/tests/Unit/Views/StylesComponentViewTest.php +++ b/packages/framework/tests/Unit/Views/StylesComponentViewTest.php @@ -73,7 +73,7 @@ public function test_styles_can_be_pushed_to_the_component_styles_stack() public function test_component_renders_tailwind_play_cdn_link_when_enabled_in_config() { config(['hyde.use_play_cdn' => true]); - $this->assertStringContainsString('', $this->renderTestView()); + $this->assertStringContainsString('', $this->renderTestView()); } public function test_component_renders_app_cdn_link_when_enabled_in_config() From 05ca65b6ac1b2a407e39555956f120e512527d80 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:07:39 +0100 Subject: [PATCH 04/21] Inject the Tailwind config to PlayCDN --- .../resources/views/layouts/styles.blade.php | 5 +++++ .../src/Framework/Services/AssetService.php | 15 +++++++++++++++ .../framework/tests/Feature/AssetServiceTest.php | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 92724a7bc77..05dfa51dc39 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -4,6 +4,11 @@ {{-- The compiled Tailwind/App styles --}} @if(config('hyde.use_play_cdn', false)) + @elseif(config('hyde.load_app_styles_from_cdn', false)) @elseif(Asset::hasMediaFile('app.css')) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index b8e5ee4f92a..76d924f2775 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -5,6 +5,8 @@ namespace Hyde\Framework\Services; use Hyde\Hyde; +use Illuminate\Support\Str; +use function str_contains; /** * Handles the retrieval of core asset files. Commonly used through the Asset facade. @@ -50,6 +52,19 @@ public function hasMediaFile(string $file): bool return file_exists(Hyde::path('_media').'/'.$file); } + public function injectTailwindConfig(): string + { + $contents = file_get_contents(Hyde::path('tailwind.config.js')); + + // return everything between the first and last curly braces + $config = Str::between($contents, '{', '}'); + + // Remove trailing commas + $config = rtrim($config, ",\n\r"); + + return $config; + } + protected function getCacheBustKey(string $file): string { if (! config('hyde.cache_busting', true)) { diff --git a/packages/framework/tests/Feature/AssetServiceTest.php b/packages/framework/tests/Feature/AssetServiceTest.php index 0250046c1ba..61fdf5c3cd9 100644 --- a/packages/framework/tests/Feature/AssetServiceTest.php +++ b/packages/framework/tests/Feature/AssetServiceTest.php @@ -53,4 +53,14 @@ public function test_media_link_returns_media_path_without_cache_key_if_cache_bu $this->assertIsString($path = $service->mediaLink('app.css')); $this->assertEquals('media/app.css', $path); } + + public function test_inject_tailwind_config_returns_extracted_tailwind_config() + { + $service = new AssetService(); + $this->assertIsString($config = $service->injectTailwindConfig()); + $this->assertStringContainsString("darkMode: 'class'", $config); + $this->assertStringContainsString('theme: {', $config); + $this->assertStringContainsString('extend: {', $config); + $this->assertStringContainsString('typography: {', $config); + } } From b2223b35d795b92ac366280ee7d04f3d87b10310 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:07:50 +0100 Subject: [PATCH 05/21] Remove plugin imports --- packages/framework/src/Framework/Services/AssetService.php | 7 +++++++ packages/framework/tests/Feature/AssetServiceTest.php | 1 + 2 files changed, 8 insertions(+) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 76d924f2775..186a1950e76 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -59,6 +59,13 @@ public function injectTailwindConfig(): string // return everything between the first and last curly braces $config = Str::between($contents, '{', '}'); + // Remove plugin imports + if (str_contains($config, 'plugins: [')) { + $tokens = explode('plugins: [', $config, 2); + $tokens[1] = Str::after($tokens[1], ']'); + $config = implode('', $tokens); + } + // Remove trailing commas $config = rtrim($config, ",\n\r"); diff --git a/packages/framework/tests/Feature/AssetServiceTest.php b/packages/framework/tests/Feature/AssetServiceTest.php index 61fdf5c3cd9..913facd0e6e 100644 --- a/packages/framework/tests/Feature/AssetServiceTest.php +++ b/packages/framework/tests/Feature/AssetServiceTest.php @@ -62,5 +62,6 @@ public function test_inject_tailwind_config_returns_extracted_tailwind_config() $this->assertStringContainsString('theme: {', $config); $this->assertStringContainsString('extend: {', $config); $this->assertStringContainsString('typography: {', $config); + $this->assertStringNotContainsString('plugins', $config); } } From 2da9e3410e3d2c7021611385b0949b4685dfa4eb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:10:18 +0100 Subject: [PATCH 06/21] Add warning to config --- config/hyde.php | 1 + packages/framework/config/hyde.php | 1 + 2 files changed, 2 insertions(+) diff --git a/config/hyde.php b/config/hyde.php index c41c689c967..0bd97f02f6a 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -193,4 +193,5 @@ // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. 'use_play_cdn' => false, + // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. ]; diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index c41c689c967..aa588e74d2c 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -192,5 +192,6 @@ 'load_app_styles_from_cdn' => false, // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. + // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. 'use_play_cdn' => false, ]; From b28131051f92ebc355548d9b9f73d2d2e1b7b285 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:11:03 +0100 Subject: [PATCH 07/21] Format HTML --- packages/framework/resources/views/layouts/styles.blade.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 05dfa51dc39..da7ca1bf337 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -4,11 +4,7 @@ {{-- The compiled Tailwind/App styles --}} @if(config('hyde.use_play_cdn', false)) - + @elseif(config('hyde.load_app_styles_from_cdn', false)) @elseif(Asset::hasMediaFile('app.css')) From e15022f94cbe16c5cd67c8d2dc715f555ed22f45 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:12:38 +0100 Subject: [PATCH 08/21] Add filepath header --- packages/framework/src/Framework/Services/AssetService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 186a1950e76..28f96e28d5b 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -69,6 +69,9 @@ public function injectTailwindConfig(): string // Remove trailing commas $config = rtrim($config, ",\n\r"); + // Add filepath header + $config = "/* tailwind.config.js */ \n".$config; + return $config; } From 9cea1c59bc84f2cee2deeb42b8d0d0dc394f3f62 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:14:16 +0100 Subject: [PATCH 09/21] Minify script --- packages/framework/src/Framework/Services/AssetService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index 28f96e28d5b..dc2db7ae43b 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -72,6 +72,9 @@ public function injectTailwindConfig(): string // Add filepath header $config = "/* tailwind.config.js */ \n".$config; + // Minify script + $config = preg_replace('/\s+/', ' ', $config); + return $config; } From 0ecb6434a883addf4c090d7862afdf1af12c6287 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:15:16 +0100 Subject: [PATCH 10/21] Clean up code --- .../src/Framework/Services/AssetService.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index dc2db7ae43b..b78aff71990 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -54,28 +54,15 @@ public function hasMediaFile(string $file): bool public function injectTailwindConfig(): string { - $contents = file_get_contents(Hyde::path('tailwind.config.js')); + $config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}'); - // return everything between the first and last curly braces - $config = Str::between($contents, '{', '}'); - - // Remove plugin imports if (str_contains($config, 'plugins: [')) { $tokens = explode('plugins: [', $config, 2); $tokens[1] = Str::after($tokens[1], ']'); $config = implode('', $tokens); } - // Remove trailing commas - $config = rtrim($config, ",\n\r"); - - // Add filepath header - $config = "/* tailwind.config.js */ \n".$config; - - // Minify script - $config = preg_replace('/\s+/', ' ', $config); - - return $config; + return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n". rtrim($config, ",\n\r")); } protected function getCacheBustKey(string $file): string From a29c76525ac4e8a35815247d60f12cba45bbc698 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:16:56 +0100 Subject: [PATCH 11/21] Decouple PlayCDN so it's a superset over the default styles so HydeFront is added --- .../framework/resources/views/layouts/styles.blade.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index da7ca1bf337..fc8d98f1018 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -2,14 +2,16 @@ {{-- The compiled Tailwind/App styles --}} -@if(config('hyde.use_play_cdn', false)) - - -@elseif(config('hyde.load_app_styles_from_cdn', false)) +@if(config('hyde.load_app_styles_from_cdn', false)) @elseif(Asset::hasMediaFile('app.css')) @endif +@if(config('hyde.use_play_cdn', false)) + + +@endif + {{-- Add any extra styles to include after the others --}} @stack('styles') From 035830a5867dad4b9f28fefbe7760f1a04370897 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:19:05 +0100 Subject: [PATCH 12/21] Add Blade comment --- packages/framework/resources/views/layouts/styles.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index fc8d98f1018..591e25b7737 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -8,6 +8,7 @@ @endif +{{-- Dynamic TailwindCSS Play CDN --}} @if(config('hyde.use_play_cdn', false)) From d491b8590b669a5a5ef8c01284c67ea7428d6208 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:21:26 +0100 Subject: [PATCH 13/21] Add console warning --- packages/framework/resources/views/layouts/styles.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index 591e25b7737..aa390c37019 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -12,6 +12,7 @@ @if(config('hyde.use_play_cdn', false)) + @endif {{-- Add any extra styles to include after the others --}} From b1ce595d485e17043fbadfaa41a48da4e9bef39e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:21:31 +0100 Subject: [PATCH 14/21] Link to the docs --- packages/framework/resources/views/layouts/styles.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/resources/views/layouts/styles.blade.php b/packages/framework/resources/views/layouts/styles.blade.php index aa390c37019..00a3135a895 100644 --- a/packages/framework/resources/views/layouts/styles.blade.php +++ b/packages/framework/resources/views/layouts/styles.blade.php @@ -12,7 +12,7 @@ @if(config('hyde.use_play_cdn', false)) - + @endif {{-- Add any extra styles to include after the others --}} From dcf82529531d4b5fb19b93781e6c2c4a7207aedc Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 22 Nov 2022 17:22:43 +0000 Subject: [PATCH 15/21] Apply fixes from StyleCI --- packages/framework/src/Framework/Services/AssetService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Services/AssetService.php b/packages/framework/src/Framework/Services/AssetService.php index b78aff71990..6a00d84b9a4 100644 --- a/packages/framework/src/Framework/Services/AssetService.php +++ b/packages/framework/src/Framework/Services/AssetService.php @@ -62,7 +62,7 @@ public function injectTailwindConfig(): string $config = implode('', $tokens); } - return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n". rtrim($config, ",\n\r")); + return preg_replace('/\s+/', ' ', "/* tailwind.config.js */ \n".rtrim($config, ",\n\r")); } protected function getCacheBustKey(string $file): string From 05d332cd6a6e22331fb5a95e2504781632407fd3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 18:24:10 +0100 Subject: [PATCH 16/21] Sync config files --- config/hyde.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hyde.php b/config/hyde.php index 0bd97f02f6a..aa588e74d2c 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -192,6 +192,6 @@ 'load_app_styles_from_cdn' => false, // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. - 'use_play_cdn' => false, // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. + 'use_play_cdn' => false, ]; From 6503e895d8b7d61845b10d360ad8b36321072dc3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 19:47:01 +0100 Subject: [PATCH 17/21] Update configuration documentation --- config/hyde.php | 13 ++++++++----- packages/framework/config/hyde.php | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index aa588e74d2c..13277d268b2 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -181,17 +181,20 @@ /* |-------------------------------------------------------------------------- - | Load app.css from CDN + | CDN Stylesheet Settings |-------------------------------------------------------------------------- | | Hyde ships with an app.css file containing compiled TailwindCSS styles - | in the _media/ directory. If you want to load this file from the - | HydeFront JsDelivr CDN, you can set this setting to true. + | with all the classes you need for all built-in pages and templates. */ + // The exact file shipped with Hyde can also be loaded from the + // HydeFront JsDelivr CDN, by setting the following option to true. 'load_app_styles_from_cdn' => false, - // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. - // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. + // The next setting enables a script for the TailwindCSS PlayCDN + // which will compile styles in the browser. While this is useful + // for local development it's not recommended for production use. + // To keep things consistent, your Tailwind configuration file will be injected into the HTML. 'use_play_cdn' => false, ]; diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index aa588e74d2c..13277d268b2 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -181,17 +181,20 @@ /* |-------------------------------------------------------------------------- - | Load app.css from CDN + | CDN Stylesheet Settings |-------------------------------------------------------------------------- | | Hyde ships with an app.css file containing compiled TailwindCSS styles - | in the _media/ directory. If you want to load this file from the - | HydeFront JsDelivr CDN, you can set this setting to true. + | with all the classes you need for all built-in pages and templates. */ + // The exact file shipped with Hyde can also be loaded from the + // HydeFront JsDelivr CDN, by setting the following option to true. 'load_app_styles_from_cdn' => false, - // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. - // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. + // The next setting enables a script for the TailwindCSS PlayCDN + // which will compile styles in the browser. While this is useful + // for local development it's not recommended for production use. + // To keep things consistent, your Tailwind configuration file will be injected into the HTML. 'use_play_cdn' => false, ]; From 481cb3889f3c89621741d8bbb091d2dba8b5855d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 19:50:39 +0100 Subject: [PATCH 18/21] Document PlayCDN feature --- docs/creating-content/managing-assets.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/creating-content/managing-assets.md b/docs/creating-content/managing-assets.md index cb339c366a6..687db384331 100644 --- a/docs/creating-content/managing-assets.md +++ b/docs/creating-content/managing-assets.md @@ -89,6 +89,14 @@ For the absolute majority of the cases, you don't need to mess with these files. #### Loading from CDN If you want to load the same pre-compiled file included with Hyde but from a CDN, you can set `load_app_styles_from_cdn` to `true` in the `config/hyde.php` file. While you lose the ability to customize it, your styles will be automatically updated when needed. +### Using the TailwindCSS Play CDN + +If you want to use the [TailwindCSS Play CDN](https://tailwindcss.com/docs/installation/play-cdn), you can set `use_play_cdn` to `true` in the `config/hyde.php` file. +This will in addition to loading the standard app.css file also add a script tag to load the TailwindCSS Play CDN. +What's even better is that Hyde will also inject the contents of the included `tailwind.config.js` file into the script tag, so the Play CDN styles match the ones created by Laravel Mix. +This also means you can tinker around with the TailwindCSS settings without having to compile anything. + +>warn Note that the Play CDN is not meant for production use, so enabling it will add a warning to the web console. ## Managing images As mentioned above, assets stored in the _media folder are automatically copied to the _site/media folder, From d607b3f473e36fdf616b4038ab18a1ba24586f58 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 19:52:03 +0100 Subject: [PATCH 19/21] Add method annotation to asset facade --- packages/framework/src/Facades/Asset.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 5a2e5b3028f..ab658c4a1a2 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -18,6 +18,7 @@ * @method static string cdnLink(string $file) * @method static string mediaLink(string $file) * @method static bool hasMediaFile(string $file) + * @method static string injectTailwindConfig() */ class Asset extends Facade { From 097686e420bd6facce700b56ad78d517ea0f9d3e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 20:35:49 +0100 Subject: [PATCH 20/21] Revert "Update configuration documentation" This reverts commit 6503e895d8b7d61845b10d360ad8b36321072dc3. --- config/hyde.php | 13 +++++-------- packages/framework/config/hyde.php | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index 13277d268b2..aa588e74d2c 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -181,20 +181,17 @@ /* |-------------------------------------------------------------------------- - | CDN Stylesheet Settings + | Load app.css from CDN |-------------------------------------------------------------------------- | | Hyde ships with an app.css file containing compiled TailwindCSS styles - | with all the classes you need for all built-in pages and templates. + | in the _media/ directory. If you want to load this file from the + | HydeFront JsDelivr CDN, you can set this setting to true. */ - // The exact file shipped with Hyde can also be loaded from the - // HydeFront JsDelivr CDN, by setting the following option to true. 'load_app_styles_from_cdn' => false, - // The next setting enables a script for the TailwindCSS PlayCDN - // which will compile styles in the browser. While this is useful - // for local development it's not recommended for production use. - // To keep things consistent, your Tailwind configuration file will be injected into the HTML. + // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. + // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. 'use_play_cdn' => false, ]; diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index 13277d268b2..aa588e74d2c 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -181,20 +181,17 @@ /* |-------------------------------------------------------------------------- - | CDN Stylesheet Settings + | Load app.css from CDN |-------------------------------------------------------------------------- | | Hyde ships with an app.css file containing compiled TailwindCSS styles - | with all the classes you need for all built-in pages and templates. + | in the _media/ directory. If you want to load this file from the + | HydeFront JsDelivr CDN, you can set this setting to true. */ - // The exact file shipped with Hyde can also be loaded from the - // HydeFront JsDelivr CDN, by setting the following option to true. 'load_app_styles_from_cdn' => false, - // The next setting enables a script for the TailwindCSS PlayCDN - // which will compile styles in the browser. While this is useful - // for local development it's not recommended for production use. - // To keep things consistent, your Tailwind configuration file will be injected into the HTML. + // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. + // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. 'use_play_cdn' => false, ]; From 83fef83e5fa63ac1135aa2a64fcb448854431810 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 22 Nov 2022 20:41:50 +0100 Subject: [PATCH 21/21] Update configuration documentation --- config/hyde.php | 14 ++++++++++++-- packages/framework/config/hyde.php | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index aa588e74d2c..fb5c4b547a2 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -187,11 +187,21 @@ | Hyde ships with an app.css file containing compiled TailwindCSS styles | in the _media/ directory. If you want to load this file from the | HydeFront JsDelivr CDN, you can set this setting to true. + | */ 'load_app_styles_from_cdn' => false, - // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. - // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. + /* + |-------------------------------------------------------------------------- + | Tailwind Play CDN + |-------------------------------------------------------------------------- + | + | The next setting enables a script for the TailwindCSS Play CDN which will + | compile CSS in the browser. While this is useful for local development + | it's not recommended for production use. To keep things consistent, + | your Tailwind configuration file will be injected into the HTML. + */ + 'use_play_cdn' => false, ]; diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index aa588e74d2c..fb5c4b547a2 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -187,11 +187,21 @@ | Hyde ships with an app.css file containing compiled TailwindCSS styles | in the _media/ directory. If you want to load this file from the | HydeFront JsDelivr CDN, you can set this setting to true. + | */ 'load_app_styles_from_cdn' => false, - // You can also load styles from the TailwindCSS PlayCDN which is useful for local development. - // Note that this is not recommended for production use and that your Tailwind config will be injected into the HTML. + /* + |-------------------------------------------------------------------------- + | Tailwind Play CDN + |-------------------------------------------------------------------------- + | + | The next setting enables a script for the TailwindCSS Play CDN which will + | compile CSS in the browser. While this is useful for local development + | it's not recommended for production use. To keep things consistent, + | your Tailwind configuration file will be injected into the HTML. + */ + 'use_play_cdn' => false, ];