Skip to content

Commit 61d6d35

Browse files
Windows Docker and Tailwind watch mode (#57)
* Add --poll-watch option * --poll-watch option documentation * Adding --poll option * Update --poll option description Co-authored-by: Victor Bocharsky <[email protected]> --------- Co-authored-by: Victor Bocharsky <[email protected]>
1 parent 1c075f2 commit 61d6d35

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

doc/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ That's it! This will watch for changes to your ``assets/styles/app.css`` file
5454
and automatically recompile it when needed. If you refresh the page, the
5555
final ``app.css`` file will already contain the compiled CSS.
5656

57+
Watch mode in Docker with Windows host
58+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59+
60+
If you work on Windows and your app is running in a Docker container, and you
61+
are having trouble with the ``--watch`` option, you can try runnig the ``tailwind:build``
62+
command with ``--poll`` option.
63+
64+
.. code-block:: terminal
65+
66+
$ php bin/console tailwind:build --watch --poll
67+
5768
Symfony CLI
5869
~~~~~~~~~~~
5970

src/Command/TailwindBuildCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected function configure(): void
3333
{
3434
$this
3535
->addOption('watch', 'w', null, 'Watch for changes and rebuild automatically')
36+
->addOption('poll', null, null, 'Use polling instead of filesystem events when watching')
3637
->addOption('minify', 'm', InputOption::VALUE_NONE, 'Minify the output CSS')
3738
;
3839
}
@@ -44,6 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4445

4546
$process = $this->tailwindBuilder->runBuild(
4647
watch: $input->getOption('watch'),
48+
poll: $input->getOption('poll'),
4749
minify: $input->getOption('minify'),
4850
);
4951
$process->wait(function ($type, $buffer) use ($io) {

src/TailwindBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ public function __construct(
4848

4949
public function runBuild(
5050
bool $watch,
51+
bool $poll,
5152
bool $minify,
5253
): Process {
5354
$binary = $this->createBinary();
5455
$arguments = ['-c', $this->configPath, '-i', $this->inputPath, '-o', $this->getInternalOutputCssPath()];
5556
if ($watch) {
5657
$arguments[] = '--watch';
58+
if ($poll) {
59+
$arguments[] = '--poll';
60+
}
5761
}
5862
if ($minify) {
5963
$arguments[] = '--minify';

tests/TailwindBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testIntegrationWithDefaultOptions(): void
4646
null,
4747
__DIR__.'/fixtures/tailwind.config.js'
4848
);
49-
$process = $builder->runBuild(watch: false, minify: false);
49+
$process = $builder->runBuild(watch: false, poll: false, minify: false);
5050
$process->wait();
5151

5252
$this->assertTrue($process->isSuccessful());
@@ -67,7 +67,7 @@ public function testIntegrationWithMinify(): void
6767
null,
6868
__DIR__.'/fixtures/tailwind.config.js'
6969
);
70-
$process = $builder->runBuild(watch: false, minify: true);
70+
$process = $builder->runBuild(watch: false, poll: false, minify: true);
7171
$process->wait();
7272

7373
$this->assertTrue($process->isSuccessful());

0 commit comments

Comments
 (0)