@@ -34,6 +34,7 @@ public function __construct(
3434 private readonly ?string $ binaryPath = null ,
3535 private readonly ?string $ binaryVersion = null ,
3636 private readonly string $ configPath = 'tailwind.config.js ' ,
37+ private readonly ?string $ postCssConfigPath = null ,
3738 ) {
3839 $ paths = [];
3940 foreach ($ inputPaths as $ inputPath ) {
@@ -48,6 +49,7 @@ public function runBuild(
4849 bool $ poll ,
4950 bool $ minify ,
5051 ?string $ inputFile = null ,
52+ ?string $ postCssConfigFile = null ,
5153 ): Process {
5254 $ binary = $ this ->createBinary ();
5355
@@ -66,6 +68,12 @@ public function runBuild(
6668 if ($ minify ) {
6769 $ arguments [] = '--minify ' ;
6870 }
71+
72+ $ postCssConfigPath = $ this ->validatePostCssConfigFile ($ postCssConfigFile ?? $ this ->postCssConfigPath );
73+ if ($ postCssConfigPath ) {
74+ $ arguments [] = '--postcss ' ;
75+ $ arguments [] = $ postCssConfigPath ;
76+ }
6977 $ process = $ binary ->createProcess ($ arguments );
7078 if ($ watch ) {
7179 $ process ->setTimeout (null );
@@ -145,6 +153,23 @@ private function validateInputFile(string $inputPath): string
145153 throw new \InvalidArgumentException (\sprintf ('The input CSS file "%s" does not exist. ' , $ inputPath ));
146154 }
147155
156+ private function validatePostCssConfigFile (?string $ postCssConfigPath ): ?string
157+ {
158+ if (null === $ postCssConfigPath ) {
159+ return null ;
160+ }
161+
162+ if (is_file ($ postCssConfigPath )) {
163+ return realpath ($ postCssConfigPath );
164+ }
165+
166+ if (is_file ($ this ->projectRootDir .'/ ' .$ postCssConfigPath )) {
167+ return realpath ($ this ->projectRootDir .'/ ' .$ postCssConfigPath );
168+ }
169+
170+ throw new \InvalidArgumentException (\sprintf ('The PostCSS config file "%s" does not exist. ' , $ postCssConfigPath ));
171+ }
172+
148173 private function createBinary (): TailwindBinary
149174 {
150175 return new TailwindBinary ($ this ->tailwindVarDir , $ this ->projectRootDir , $ this ->binaryPath , $ this ->binaryVersion , $ this ->cache , $ this ->output );
0 commit comments