File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
packages/vite/src/TagsResolver Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -177,10 +177,16 @@ private function resolvePrefetchingScript(Chunk $chunk): ?string
177177 return $ assets ;
178178 };
179179
180- $ assets = Json \encode ( array_values (array_map (
180+ $ assets = array_values (array_map (
181181 callback: fn (array $ asset ) => array_map ('strval ' , $ asset ),
182182 array: array_unique ($ findPrefetchableAssets ($ chunk ), flags: SORT_REGULAR ),
183- )));
183+ ));
184+
185+ if (count ($ assets ) === 0 ) {
186+ return null ;
187+ }
188+
189+ $ assets = Json \encode ($ assets );
184190
185191 $ script = match ($ this ->viteConfig ->prefetching ->strategy ) {
186192 PrefetchStrategy::AGGRESSIVE => <<<JS
@@ -191,7 +197,7 @@ function makeLink(asset) {
191197 return link
192198 }
193199
194- const fragment = new DocumentFragment()
200+ const fragment = new DocumentFragment();
195201 {$ assets }.forEach((asset) => fragment.append(makeLink(asset)))
196202 document.head.append(fragment)
197203 }))
You can’t perform that action at this time.
0 commit comments