Skip to content

Commit

Permalink
Use the watch=always flag instead of just watch
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Jan 23, 2025
1 parent 12e790d commit 6a28746
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function handle()
$sourcePath = $this->fixFilePathForOs(config('tailwindcss.build.source_file_path'));
$sourceRelativePath = str_replace(rtrim(resource_path(), DIRECTORY_SEPARATOR), '', $sourcePath);
$destinationPath = $this->fixFilePathForOs(config('tailwindcss.build.destination_path'));
$destinationFileAbsolutePath = $destinationPath.DIRECTORY_SEPARATOR.trim($sourceRelativePath, DIRECTORY_SEPARATOR);
$destinationFileAbsolutePath = $destinationPath . DIRECTORY_SEPARATOR . trim($sourceRelativePath, DIRECTORY_SEPARATOR);
$destinationFileRelativePath = str_replace(rtrim(public_path(), DIRECTORY_SEPARATOR), '', $destinationFileAbsolutePath);

File::ensureDirectoryExists(dirname($destinationFileAbsolutePath));
Expand All @@ -55,7 +55,7 @@ public function handle()
$binFile,
'-i', $sourcePath,
'-o', $destinationFileAbsolutePath,
$this->option('watch') ? '-w' : null,
$this->option('watch') ? '--watch=always' : null,
$this->shouldMinify() ? '-m' : null,
]), function ($type, $output) {
$this->output->write($output);
Expand All @@ -79,6 +79,21 @@ public function handle()
return self::SUCCESS;
}

protected function ensureAssetIsVersioned(string $generatedFile): string
{
$digest = sha1_file($generatedFile);

$versionedFile = preg_replace(
'/(\.css)$/',
sprintf('-%s$1', $digest),
$generatedFile,
);

File::move($generatedFile, $versionedFile);

return $versionedFile;
}

private function fixFilePathForOs(string $path): string
{
return str_replace('/', DIRECTORY_SEPARATOR, $path);
Expand All @@ -98,19 +113,4 @@ private function shouldMinify(): bool
{
return $this->option('minify') || $this->option('prod');
}

protected function ensureAssetIsVersioned(string $generatedFile): string
{
$digest = sha1_file($generatedFile);

$versionedFile = preg_replace(
'/(\.css)$/',
sprintf('-%s$1', $digest),
$generatedFile,
);

File::move($generatedFile, $versionedFile);

return $versionedFile;
}
}

0 comments on commit 6a28746

Please sign in to comment.