@@ -21,34 +21,32 @@ class TailwindService
2121 /**
2222 * Build CSS or return cached file.
2323 *
24- * @param string $package Relative package path (e.g. packages/sSeo)
24+ * @param string $input Relative package file of style (e.g. packages/sSeo/css/tailwind.css )
2525 * @param bool $forceRebuild Ignore cache
2626 * @return string Public URL to compiled CSS
2727 */
28- public function compile (string $ package , bool $ forceRebuild = false ): string
28+ public function compile (string $ input , bool $ forceRebuild = false ): string
2929 {
30- $ base = EVO_BASE_PATH . $ package . '/ ' ;
31- $ input = $ base . 'tailwind.css ' ;
32- $ output = $ base . "{$ this ->buildDir }tailwind.min.css " ;
30+ $ output = str_replace ('.css ' , '.min.css ' , $ input );
3331
3432 if (!$ forceRebuild && is_file ($ output )) {
35- $ hash = Cache::get ("tw: {$ package }" );
33+ $ hash = Cache::get ("tw: {$ input }" );
3634 $ cur = md5_file ($ input );
3735 if ($ hash === $ cur ) {
38- return " / { $ package } / { $ this -> buildDir } tailwind.min.css " ;
36+ return str_replace ( EVO_BASE_PATH , ' / ' , $ output ) ;
3937 }
4038 }
4139
4240 if (!is_file ($ input )) {
43- throw new RuntimeException ("Tailwind sources not found for « {$ package }». " );
41+ throw new RuntimeException ("Tailwind sources not found for « {$ input }». " );
4442 }
4543
4644 $ this ->ensureBinary ();
4745
4846 if (!is_dir (dirname ($ output ))
4947 && !mkdir (dirname ($ output ), 0775 , true )
5048 && !is_dir (dirname ($ output ))) {
51- throw new RuntimeException ("Cannot create build dir for « {$ package }». " );
49+ throw new RuntimeException ("Cannot create build dir for « {$ input }». " );
5250 }
5351
5452 $ tmpPath = EVO_CORE_PATH . 'storage/tmp ' ;
@@ -68,9 +66,9 @@ public function compile(string $package, bool $forceRebuild = false): string
6866 }
6967
7068 $ hash = md5_file ($ input );
71- Cache::put ("tw: {$ package }" , $ hash , $ this ->ttl );
69+ Cache::put ("tw: {$ input }" , $ hash , $ this ->ttl );
7270
73- return " / { $ package } / { $ this -> buildDir } tailwind.min.css " ;
71+ return str_replace ( EVO_BASE_PATH , ' / ' , $ output ) ;
7472 }
7573
7674 /**
@@ -86,8 +84,8 @@ protected function ensureBinary(): void
8684
8785 // Determine a platform (basic)
8886 [$ os , $ arch ] = $ this ->detectPlatform (); // linux/macos/windows | x64/arm64
89- $ ext = $ os === 'windows ' ? '.exe ' : '' ;
90- $ url = sprintf (
87+ $ ext = $ os === 'windows ' ? '.exe ' : '' ;
88+ $ url = sprintf (
9189 'https://github.com/tailwindlabs/tailwindcss/releases/latest/download/ '
9290 .'tailwindcss-%s-%s%s ' ,
9391 $ os , $ arch , $ ext
0 commit comments