@@ -6,25 +6,31 @@ products:
66date : 2025-06-27T12:00:00Z
77---
88
9- All of Vite's [ static asset handling] ( https://vite.dev/guide/assets ) features are now supported in your Worker as well as in your frontend.
9+ You can now use any of Vite's [ static asset handling] ( https://vite.dev/guide/assets ) features in your Worker as well as in your frontend.
1010These include importing assets as URLs, importing as strings and importing from the ` public ` directory as well as inlining assets.
1111
1212Additionally, assets imported as URLs in your Worker are now automatically moved to the client build output.
1313
14- Here's an example that fetches an imported asset using the [ assets binding] ( /workers/static-assets/binding/#binding ) and modifies the response.
14+ Here is an example that fetches an imported asset using the [ assets binding] ( /workers/static-assets/binding/#binding ) and modifies the response.
1515
1616``` ts
17+ // Import the asset URL
18+ // This returns the resolved path in development and production
1719import myImage from " ./my-image.png" ;
1820
1921export default {
2022 async fetch(request , env ) {
23+ // Fetch the asset using the binding
2124 const response = await env .ASSETS .fetch (new URL (myImage , request .url ));
25+ // Create a new `Response` object that can be modified
2226 const modifiedResponse = new Response (response .body , response );
27+ // Add an additional header
2328 modifiedResponse .headers .append (" my-header" , " imported-asset" );
2429
30+ // Return the modfied response
2531 return modifiedResponse ;
2632 },
2733};
2834```
2935
30- See [ Static Assets] ( /workers/vite-plugin/reference/static-assets/ ) in the Vite plugin docs for more info.
36+ Refer to [ Static Assets] ( /workers/vite-plugin/reference/static-assets/ ) in the Cloudflare Vite plugin docs for more info.
0 commit comments