1515
1616class SassBuilder
1717{
18- private ?SymfonyStyle $ output = null ;
19-
20- /**
21- * @var array<string, bool|string>
22- */
23- private array $ sassOptions ;
24-
2518 /**
2619 * Run "sass --help" to see all options.
2720 *
@@ -44,6 +37,13 @@ class SassBuilder
4437 '--[no-]trace ' => null , // Print full Dart stack traces for exceptions.
4538 ];
4639
40+ private ?SymfonyStyle $ output = null ;
41+
42+ /**
43+ * @var array<string, bool|string>
44+ */
45+ private array $ sassOptions ;
46+
4747 /**
4848 * @param array<string> $sassPaths
4949 * @param array<string, bool|string> $sassOptions
@@ -66,6 +66,16 @@ public function __construct(
6666 $ this ->setOptions ($ sassOptions );
6767 }
6868
69+ /**
70+ * @internal
71+ */
72+ public static function guessCssNameFromSassFile (string $ sassFile , string $ outputDirectory ): string
73+ {
74+ $ fileName = basename ($ sassFile , '.scss ' );
75+
76+ return $ outputDirectory .'/ ' .$ fileName .'.output.css ' ;
77+ }
78+
6979 public function runBuild (bool $ watch ): Process
7080 {
7181 $ binary = $ this ->createBinary ();
@@ -95,11 +105,6 @@ public function runBuild(bool $watch): Process
95105 return $ process ;
96106 }
97107
98- private function createBinary (): SassBinary
99- {
100- return new SassBinary ($ this ->projectRootDir .'/var ' , $ this ->binaryPath , $ this ->output );
101- }
102-
103108 /**
104109 * @return array<string>
105110 */
@@ -117,16 +122,6 @@ public function getScssCssTargets(): array
117122 return $ targets ;
118123 }
119124
120- /**
121- * @internal
122- */
123- public static function guessCssNameFromSassFile (string $ sassFile , string $ outputDirectory ): string
124- {
125- $ fileName = basename ($ sassFile , '.scss ' );
126-
127- return $ outputDirectory .'/ ' .$ fileName .'.output.css ' ;
128- }
129-
130125 /**
131126 * @param array<string, bool|string> $options
132127 *
@@ -159,14 +154,29 @@ public function getBuildOptions(array $options = []): array
159154 }
160155 }
161156
162- return $ buildOptions ;
157+ // Filter forbidden associations of options.
158+ if (\in_array ('--no-source-map ' , $ buildOptions , true )) {
159+ $ buildOptions = array_diff ($ buildOptions , [
160+ '--embed-sources ' ,
161+ '--embed-source-map ' ,
162+ '--no-embed-sources ' ,
163+ '--no-embed-source-map ' ,
164+ ]);
165+ }
166+
167+ return array_values ($ buildOptions );
163168 }
164169
165170 public function setOutput (SymfonyStyle $ output ): void
166171 {
167172 $ this ->output = $ output ;
168173 }
169174
175+ private function createBinary (): SassBinary
176+ {
177+ return new SassBinary ($ this ->projectRootDir .'/var ' , $ this ->binaryPath , $ this ->output );
178+ }
179+
170180 /**
171181 * Save the Sass options for the build.
172182 *
0 commit comments