diff --git a/src/SassBuilder.php b/src/SassBuilder.php index 64c13d9..f267d9d 100644 --- a/src/SassBuilder.php +++ b/src/SassBuilder.php @@ -15,13 +15,6 @@ class SassBuilder { - private ?SymfonyStyle $output = null; - - /** - * @var array - */ - private array $sassOptions; - /** * Run "sass --help" to see all options. * @@ -44,6 +37,13 @@ class SassBuilder '--[no-]trace' => null, // Print full Dart stack traces for exceptions. ]; + private ?SymfonyStyle $output = null; + + /** + * @var array + */ + private array $sassOptions; + /** * @param array $sassPaths * @param array $sassOptions @@ -66,6 +66,16 @@ public function __construct( $this->setOptions($sassOptions); } + /** + * @internal + */ + public static function guessCssNameFromSassFile(string $sassFile, string $outputDirectory): string + { + $fileName = basename($sassFile, '.scss'); + + return $outputDirectory.'/'.$fileName.'.output.css'; + } + public function runBuild(bool $watch): Process { $binary = $this->createBinary(); @@ -95,11 +105,6 @@ public function runBuild(bool $watch): Process return $process; } - private function createBinary(): SassBinary - { - return new SassBinary($this->projectRootDir.'/var', $this->binaryPath, $this->output); - } - /** * @return array */ @@ -117,16 +122,6 @@ public function getScssCssTargets(): array return $targets; } - /** - * @internal - */ - public static function guessCssNameFromSassFile(string $sassFile, string $outputDirectory): string - { - $fileName = basename($sassFile, '.scss'); - - return $outputDirectory.'/'.$fileName.'.output.css'; - } - /** * @param array $options * @@ -159,7 +154,17 @@ public function getBuildOptions(array $options = []): array } } - return $buildOptions; + // Filter forbidden associations of options. + if (\in_array('--no-source-map', $buildOptions, true)) { + $buildOptions = array_diff($buildOptions, [ + '--embed-sources', + '--embed-source-map', + '--no-embed-sources', + '--no-embed-source-map', + ]); + } + + return array_values($buildOptions); } public function setOutput(SymfonyStyle $output): void @@ -167,6 +172,11 @@ public function setOutput(SymfonyStyle $output): void $this->output = $output; } + private function createBinary(): SassBinary + { + return new SassBinary($this->projectRootDir.'/var', $this->binaryPath, $this->output); + } + /** * Save the Sass options for the build. * diff --git a/tests/SassBuilderTest.php b/tests/SassBuilderTest.php index c7269e3..097c3c6 100644 --- a/tests/SassBuilderTest.php +++ b/tests/SassBuilderTest.php @@ -247,8 +247,6 @@ public static function provideSassPhpOptions() '--no-charset', '--no-error-css', '--no-source-map', - '--no-embed-sources', - '--no-embed-source-map', '--no-quiet', '--no-quiet-deps', '--no-stop-on-error',