File tree Expand file tree Collapse file tree 3 files changed +50
-7
lines changed
Expand file tree Collapse file tree 3 files changed +50
-7
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function resolveTags(array $entrypoints): array
3535 ->prepend ($ this ->createDevelopmentTag (self ::CLIENT_SCRIPT_PATH ));
3636
3737 if ($ this ->bridgeFile ->needsReactRefresh ) {
38- $ tags ->prepend ($ this ->createReactRefreshTag ());
38+ $ tags = $ tags ->prepend ($ this ->createReactRefreshTag ());
3939 }
4040
4141 return $ tags ->toArray ();
@@ -72,11 +72,11 @@ private function createReactRefreshTag(): string
7272 {
7373 return <<<HTML
7474 <script type="module">
75- import RefreshRuntime from ' {$ this ->bridgeFile ->url }/@react-refresh'
76- RefreshRuntime.injectIntoGlobalHook(window)
77- window. \$RefreshReg$ = () => {}
78- window. \$RefreshSig$ = () => (type) => type
79- window.__vite_plugin_react_preamble_installed__ = true
75+ import RefreshRuntime from ' {$ this ->bridgeFile ->url }/@react-refresh';
76+ RefreshRuntime.injectIntoGlobalHook(window);
77+ window. \$RefreshReg$ = () => {};
78+ window. \$RefreshSig$ = () => (type) => type;
79+ window.__vite_plugin_react_preamble_installed__ = true;
8080 </script>
8181 HTML ;
8282 }
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ private function getBridgeFile(): ViteBridgeFile
140140
141141 return static ::$ bridgeFile = new ViteBridgeFile (
142142 url: $ content ->get ('url ' ),
143- needsReactRefresh: $ content ->get ('needsReactRefresh ' , false ),
143+ needsReactRefresh: $ content ->get ('needsReactRefresh ' , default: false ),
144144 );
145145 }
146146
Original file line number Diff line number Diff line change @@ -121,6 +121,49 @@ public function test_dev_entrypoints_from_config(): void
121121 );
122122 }
123123
124+ public function test_dev_entrypoints_from_config_and_react_refresh_from_bridgefile (): void
125+ {
126+ $ this ->vite ->call (
127+ callback: function (): void {
128+ $ this ->container ->config (new ViteConfig (
129+ entrypoints: ['src/foo.ts ' , 'src/bar.css ' ],
130+ ));
131+
132+ $ html = $ this ->render (<<<'HTML'
133+ <html lang="en">
134+ <head>
135+ <x-vite-tags :entrypoint="['src/foo.ts', 'src/bar.css']" />
136+ </head>
137+ <body>Foo</body>
138+ </html>
139+ HTML);
140+
141+ $ this ->assertSnippetsMatch (
142+ expected: <<<HTML
143+ <html lang="en"><head>
144+ <script type="module">
145+ import RefreshRuntime from 'http://localhost:5173/@react-refresh';
146+ RefreshRuntime.injectIntoGlobalHook(window);
147+ window. \$RefreshReg$ = () => {};
148+ window. \$RefreshSig$ = () => (type) => type;
149+ window.__vite_plugin_react_preamble_installed__ = true;
150+ </script><script type="module" src="http://localhost:5173/@vite/client"></script><script type="module" src="http://localhost:5173/src/foo.ts"></script><link rel="stylesheet" href="http://localhost:5173/src/bar.css" /></head><body>Foo
151+ </body></html>
152+ HTML ,
153+ actual: $ html ,
154+ );
155+ },
156+ files: [
157+ 'public/vite-tempest ' => [
158+ 'url ' => 'http://localhost:5173 ' ,
159+ 'needsReactRefresh ' => true ,
160+ ],
161+ 'src/foo.ts ' => '' ,
162+ 'src/bar.css ' => '' ,
163+ ],
164+ );
165+ }
166+
124167 public function test_production_entrypoint_from_config (): void
125168 {
126169 $ this ->vite ->call (
You can’t perform that action at this time.
0 commit comments