Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions src/Command/TailwindBuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,34 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);
$this->tailwindBuilder->setOutput($io);

$process = $this->tailwindBuilder->runBuild(
watch: $input->getOption('watch'),
poll: $input->getOption('poll'),
minify: $input->getOption('minify'),
inputFile: $input->getArgument('input_css'),
postCssConfigFile: $input->getOption('postcss'),
);
$process->wait(static function ($type, $buffer) use ($io) {
$io->write($buffer);
});
$inputFile = $input->getArgument('input_css');
// Tailwind takes a single input per run, so each configured file gets its own process.
// They are started together, which is also what makes --watch work for all of them.
$inputFiles = null !== $inputFile ? [$inputFile] : $this->tailwindBuilder->getInputCssPaths();

if (!$process->isSuccessful()) {
$processes = [];

foreach ($inputFiles as $file) {
$processes[] = $this->tailwindBuilder->runBuild(
watch: $input->getOption('watch'),
poll: $input->getOption('poll'),
minify: $input->getOption('minify'),
inputFile: $file,
postCssConfigFile: $input->getOption('postcss'),
);
}

$failed = false;

foreach ($processes as $process) {
$process->wait(static function ($type, $buffer) use ($io) {
$io->write($buffer);
});

$failed = $failed || !$process->isSuccessful();
}

if ($failed) {
$io->error('Tailwind CSS build failed: see output above.');

return self::FAILURE;
Expand Down
24 changes: 24 additions & 0 deletions tests/Command/TailwindBuildCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,28 @@ public function testBuild(): void
$tester->assertCommandIsSuccessful();
$this->assertFileExists($builtCss);
}

public function testBuildEveryConfiguredInput(): void
{
self::bootKernel([
'project_dir' => $this->tempDir,
'tailwind_config' => [
'input_css' => [
self::FIXTURES_DIR.'/assets/styles/v4.css',
self::FIXTURES_DIR.'/assets/styles/second.css',
],
'binary_version' => 'v4.0.7',
],
]);

$this->assertFileDoesNotExist($this->tempDir.'/var/tailwind/v4.built.css');
$this->assertFileDoesNotExist($this->tempDir.'/var/tailwind/second.built.css');

$tester = $this->commandTester('tailwind:build');
$tester->execute([]);

$tester->assertCommandIsSuccessful();
$this->assertFileExists($this->tempDir.'/var/tailwind/v4.built.css');
$this->assertFileExists($this->tempDir.'/var/tailwind/second.built.css');
}
}
Loading