File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/Illuminate/Foundation Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 7
7
use Illuminate \Support \Collection ;
8
8
use Illuminate \Support \HtmlString ;
9
9
use Illuminate \Support \Str ;
10
+ use Illuminate \Support \Traits \Macroable ;
10
11
11
12
class Vite implements Htmlable
12
13
{
14
+ use Macroable;
15
+
13
16
/**
14
17
* The Content Security Policy nonce to apply to all generated tags.
15
18
*
Original file line number Diff line number Diff line change @@ -614,6 +614,25 @@ public function testViteCanOverrideHotFilePath()
614
614
$ this ->cleanViteHotFile ('cold ' );
615
615
}
616
616
617
+ public function testViteIsMacroable ()
618
+ {
619
+ $ this ->makeViteManifest ([
620
+ 'resources/images/profile.png ' => [
621
+ 'src ' => 'resources/images/profile.png ' ,
622
+ 'file ' => 'assets/profile.versioned.png ' ,
623
+ ],
624
+ ], $ buildDir = Str::random ());
625
+ Vite::macro ('image ' , function ($ asset , $ buildDir = null ) {
626
+ return $ this ->asset ("resources/images/ {$ asset }" , $ buildDir );
627
+ });
628
+
629
+ $ path = ViteFacade::image ('profile.png ' , $ buildDir );
630
+
631
+ $ this ->assertSame ("https://example.com/ {$ buildDir }/assets/profile.versioned.png " , $ path );
632
+
633
+ $ this ->cleanViteManifest ($ buildDir );
634
+ }
635
+
617
636
protected function makeViteManifest ($ contents = null , $ path = 'build ' )
618
637
{
619
638
app ()->singleton ('path.public ' , fn () => __DIR__ );
You can’t perform that action at this time.
0 commit comments