From ed54a77ff85be1c0ffa1ed4684ea3da071515344 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 12:31:14 +0100 Subject: [PATCH 01/15] Update TailwindInitCommand.php --- src/Command/TailwindInitCommand.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Command/TailwindInitCommand.php b/src/Command/TailwindInitCommand.php index 39dbbeb..d9dafaa 100644 --- a/src/Command/TailwindInitCommand.php +++ b/src/Command/TailwindInitCommand.php @@ -49,8 +49,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function createTailwindConfig(SymfonyStyle $io): bool { - if (file_exists($this->projectDir.'/tailwind.config.js')) { - $io->note('tailwind.config.js found: Tailwind CSS is already initialized.'); + $configFile = $this->tailwindBuilder->getConfigFilePath(); + if (file_exists($configFile)) { + $io->note(sprintf('Tailwind config file already exists in "%s"', $configFile)); return true; } @@ -85,7 +86,7 @@ private function createTailwindConfig(SymfonyStyle $io): bool EOF; - file_put_contents($this->projectDir.'/tailwind.config.js', $tailwindConfig); + file_put_contents($configFile, $tailwindConfig); return true; } From fff98241efa319e6532dddd3422fa88718249239 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 12:31:51 +0100 Subject: [PATCH 02/15] Update services.php --- config/services.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/services.php b/config/services.php index 7ac7aed..e087fcd 100644 --- a/config/services.php +++ b/config/services.php @@ -17,6 +17,7 @@ ->args([ param('kernel.project_dir'), abstract_arg('path to source Tailwind CSS file'), + abstract_arg('path to source Tailwind CSS config file'), param('kernel.project_dir').'/var/tailwind', abstract_arg('path to tailwind binary'), ]) From c6d18ce762dfaceccc1cf1da00a86dd1523acc14 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 12:34:16 +0100 Subject: [PATCH 03/15] Update TailwindBuilder.php --- src/TailwindBuilder.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TailwindBuilder.php b/src/TailwindBuilder.php index b2cec4d..af38dc9 100644 --- a/src/TailwindBuilder.php +++ b/src/TailwindBuilder.php @@ -28,6 +28,7 @@ class TailwindBuilder public function __construct( private readonly string $projectRootDir, string $inputPath, + private readonly string $configPath, private readonly string $tailwindVarDir, private readonly ?string $binaryPath = null, ) { @@ -47,7 +48,7 @@ public function runBuild( bool $minify, ): Process { $binary = $this->createBinary(); - $arguments = ['-i', $this->inputPath, '-o', $this->getInternalOutputCssPath()]; + $arguments = ['-c', $this->configPath, '-i', $this->inputPath, '-o', $this->getInternalOutputCssPath()]; if ($watch) { $arguments[] = '--watch'; } @@ -104,6 +105,11 @@ public function getInputCssPath(): string return $this->inputPath; } + public function getConfigFilePath(): string + { + return $this->configPath; + } + public function getOutputCssContent(): string { if (!is_file($this->getInternalOutputCssPath())) { From d9ab55a236f63b4964a92e7099e3e92a750be52d Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 12:38:22 +0100 Subject: [PATCH 04/15] Update index.rst --- doc/index.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/index.rst b/doc/index.rst index 29314f4..9523fd0 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -97,6 +97,15 @@ directives): symfonycasts_tailwind: input_css: 'assets/styles/other.css' +Another option is the ``config_file`` option, which defaults to ``tailwind.config.js``. +This represents the Tailwind configuration file: + +.. code-block:: yaml + + # config/packages/symfonycasts_tailwind.yaml + symfonycasts_tailwind: + config_file: 'tailwind.config.js' + Using a Different Binary ------------------------ From caf7b1a33999596213ffa9afa75b4b57fa4c3979 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 12:42:48 +0100 Subject: [PATCH 05/15] Update TailwindExtension.php --- src/DependencyInjection/TailwindExtension.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/TailwindExtension.php b/src/DependencyInjection/TailwindExtension.php index 131f86e..29806d2 100644 --- a/src/DependencyInjection/TailwindExtension.php +++ b/src/DependencyInjection/TailwindExtension.php @@ -29,7 +29,8 @@ public function load(array $configs, ContainerBuilder $container): void $container->findDefinition('tailwind.builder') ->replaceArgument(1, $config['input_css']) - ->replaceArgument(3, $config['binary']) + ->replaceArgument(2, $config['config_file']) + ->replaceArgument(4, $config['binary']) ; } @@ -55,6 +56,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->info('Path to CSS file to process through Tailwind') ->defaultValue('%kernel.project_dir%/assets/styles/app.css') ->end() + ->scalarNode('config_file') + ->info('Path to the tailwind.config.js file') + ->defaultValue('%kernel.project_dir%/tailwind.config.js') + ->end() ->scalarNode('binary') ->info('The tailwind binary to use instead of downloading a new one') ->defaultNull() From 06d7ba1942bbf34c13fc5fc928387b35921709f4 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 15:22:57 +0100 Subject: [PATCH 06/15] Update TailwindBuilderTest.php --- tests/TailwindBuilderTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TailwindBuilderTest.php b/tests/TailwindBuilderTest.php index da2916b..13a7a12 100644 --- a/tests/TailwindBuilderTest.php +++ b/tests/TailwindBuilderTest.php @@ -39,6 +39,7 @@ public function testIntegrationWithDefaultOptions(): void $builder = new TailwindBuilder( __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', + __DIR__.'/fixtures/tailwind.config.js', __DIR__.'/fixtures/var/tailwind' ); $process = $builder->runBuild(watch: false, minify: false); @@ -56,6 +57,7 @@ public function testIntegrationWithMinify(): void $builder = new TailwindBuilder( __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', + __DIR__.'/fixtures/tailwind.config.js', __DIR__.'/fixtures/var/tailwind' ); $process = $builder->runBuild(watch: false, minify: true); From 51d5a7c7a0e991c42746b52cb2c1cbebf51028ef Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 15:33:25 +0100 Subject: [PATCH 07/15] Update TailwindInitCommand.php --- src/Command/TailwindInitCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Command/TailwindInitCommand.php b/src/Command/TailwindInitCommand.php index d9dafaa..7e0af32 100644 --- a/src/Command/TailwindInitCommand.php +++ b/src/Command/TailwindInitCommand.php @@ -24,7 +24,6 @@ class TailwindInitCommand extends Command { public function __construct( private TailwindBuilder $tailwindBuilder, - private string $projectDir, ) { parent::__construct(); } From b939a2f98f2e4cbaa299dc22f12a701c3faca05c Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Wed, 22 Nov 2023 15:33:48 +0100 Subject: [PATCH 08/15] Update services.php --- config/services.php | 1 - 1 file changed, 1 deletion(-) diff --git a/config/services.php b/config/services.php index e087fcd..d60f67b 100644 --- a/config/services.php +++ b/config/services.php @@ -31,7 +31,6 @@ ->set('tailwind.command.init', TailwindInitCommand::class) ->args([ service('tailwind.builder'), - param('kernel.project_dir'), ]) ->tag('console.command') From 5611abac066bd73df6e6e766b7e58a57980e04d4 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 14:03:12 +0100 Subject: [PATCH 09/15] Update config/services.php Co-authored-by: Victor Bocharsky --- config/services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/services.php b/config/services.php index d60f67b..0e4d0c2 100644 --- a/config/services.php +++ b/config/services.php @@ -17,7 +17,7 @@ ->args([ param('kernel.project_dir'), abstract_arg('path to source Tailwind CSS file'), - abstract_arg('path to source Tailwind CSS config file'), + abstract_arg('path to Tailwind CSS config file'), param('kernel.project_dir').'/var/tailwind', abstract_arg('path to tailwind binary'), ]) From 8db22ba3616cf47547b35d5276cf9dc507a5060f Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 14:06:33 +0100 Subject: [PATCH 10/15] Update TailwindBuilder.php --- src/TailwindBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TailwindBuilder.php b/src/TailwindBuilder.php index af38dc9..9b6ab44 100644 --- a/src/TailwindBuilder.php +++ b/src/TailwindBuilder.php @@ -28,9 +28,9 @@ class TailwindBuilder public function __construct( private readonly string $projectRootDir, string $inputPath, - private readonly string $configPath, private readonly string $tailwindVarDir, private readonly ?string $binaryPath = null, + private readonly string $configPath = 'tailwind.config.js', ) { if (is_file($inputPath)) { $this->inputPath = $inputPath; From e44655bd5c8b699d18adf427d83939b266f090be Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 14:07:23 +0100 Subject: [PATCH 11/15] Update TailwindBuilderTest.php --- tests/TailwindBuilderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/TailwindBuilderTest.php b/tests/TailwindBuilderTest.php index 13a7a12..21666e7 100644 --- a/tests/TailwindBuilderTest.php +++ b/tests/TailwindBuilderTest.php @@ -39,8 +39,8 @@ public function testIntegrationWithDefaultOptions(): void $builder = new TailwindBuilder( __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', - __DIR__.'/fixtures/tailwind.config.js', - __DIR__.'/fixtures/var/tailwind' + __DIR__.'/fixtures/var/tailwind', + __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: false); $process->wait(); @@ -57,8 +57,8 @@ public function testIntegrationWithMinify(): void $builder = new TailwindBuilder( __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', - __DIR__.'/fixtures/tailwind.config.js', - __DIR__.'/fixtures/var/tailwind' + __DIR__.'/fixtures/var/tailwind', + __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: true); $process->wait(); From 43355701d8da5128b416a8cbc7bab7e450e9824f Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 14:09:02 +0100 Subject: [PATCH 12/15] Update TailwindExtension.php --- src/DependencyInjection/TailwindExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/TailwindExtension.php b/src/DependencyInjection/TailwindExtension.php index 29806d2..2056230 100644 --- a/src/DependencyInjection/TailwindExtension.php +++ b/src/DependencyInjection/TailwindExtension.php @@ -29,8 +29,8 @@ public function load(array $configs, ContainerBuilder $container): void $container->findDefinition('tailwind.builder') ->replaceArgument(1, $config['input_css']) - ->replaceArgument(2, $config['config_file']) - ->replaceArgument(4, $config['binary']) + ->replaceArgument(3, $config['binary']) + ->replaceArgument(4, $config['config_file']) ; } From 65f0d1a37dfeaf2859a43b2a3d9a8917f1edfad8 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 17:00:44 +0100 Subject: [PATCH 13/15] Update services.php --- config/services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/services.php b/config/services.php index 0e4d0c2..6dae81b 100644 --- a/config/services.php +++ b/config/services.php @@ -17,9 +17,9 @@ ->args([ param('kernel.project_dir'), abstract_arg('path to source Tailwind CSS file'), - abstract_arg('path to Tailwind CSS config file'), param('kernel.project_dir').'/var/tailwind', abstract_arg('path to tailwind binary'), + abstract_arg('path to Tailwind CSS config file'), ]) ->set('tailwind.command.build', TailwindBuildCommand::class) From 02f4e6b174bdcd2b07da1bf0921325ea3fd12cc0 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Mon, 27 Nov 2023 17:14:59 +0100 Subject: [PATCH 14/15] Update TailwindBuilderTest.php --- tests/TailwindBuilderTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TailwindBuilderTest.php b/tests/TailwindBuilderTest.php index 21666e7..1949896 100644 --- a/tests/TailwindBuilderTest.php +++ b/tests/TailwindBuilderTest.php @@ -40,6 +40,7 @@ public function testIntegrationWithDefaultOptions(): void __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', __DIR__.'/fixtures/var/tailwind', + null, __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: false); @@ -58,6 +59,7 @@ public function testIntegrationWithMinify(): void __DIR__.'/fixtures', __DIR__.'/fixtures/assets/styles/app.css', __DIR__.'/fixtures/var/tailwind', + null, __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: true); From 3fb0149f3f6719b1837f2cb178091b1a607d90c3 Mon Sep 17 00:00:00 2001 From: Mrtn Schndlr Date: Sat, 16 Dec 2023 09:38:51 +0100 Subject: [PATCH 15/15] Update TailwindBuilderTest.php --- tests/TailwindBuilderTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TailwindBuilderTest.php b/tests/TailwindBuilderTest.php index 1949896..2a54072 100644 --- a/tests/TailwindBuilderTest.php +++ b/tests/TailwindBuilderTest.php @@ -41,6 +41,7 @@ public function testIntegrationWithDefaultOptions(): void __DIR__.'/fixtures/assets/styles/app.css', __DIR__.'/fixtures/var/tailwind', null, + null, __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: false); @@ -60,6 +61,7 @@ public function testIntegrationWithMinify(): void __DIR__.'/fixtures/assets/styles/app.css', __DIR__.'/fixtures/var/tailwind', null, + null, __DIR__.'/fixtures/tailwind.config.js' ); $process = $builder->runBuild(watch: false, minify: true);