You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a Bun server with bun run src/backend.ts, the bundler automatically processes imported HTML files and replaces asset references (like CSS, fonts, etc.) with hashed URLs in the format /_bun/asset/9a31ffb20fe835e8.[ext].
The paths seem available when using Bun.build programmatically:
constresult=awaitBun.build({entrypoints: ["./src/backend.ts"],});// result.outputs contains BuildArtifact[] with file paths
However, I need to access these hashed filepaths programmatically at runtime (e.g., to list all bundled assets or generate dynamic references).
Question: Is there a way to access these paths without using Bun.build when running the server directly (bun run src/backend.ts)? For example:
importindexfrom"./frontend/index.html";Bun.serve({routes: {"/": index,"/list-bundled-files": ()=>{// Is there something like this?constassets=Bun.getBundledAssets();// Imagined APIreturnnewResponse(JSON.stringify(assets));},},});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When running a Bun server with
bun run src/backend.ts
, the bundler automatically processes imported HTML files and replaces asset references (like CSS, fonts, etc.) with hashed URLs in the format/_bun/asset/9a31ffb20fe835e8.[ext]
.The paths seem available when using
Bun.build
programmatically:However, I need to access these hashed filepaths programmatically at runtime (e.g., to list all bundled assets or generate dynamic references).
Question: Is there a way to access these paths without using
Bun.build
when running the server directly (bun run src/backend.ts
)? For example:Beta Was this translation helpful? Give feedback.
All reactions