## Summary
When `rollupOptions.output.entryFileNames` is customized in vite config
(e.g. `[hash].mjs`), the generated `server.js` was hardcoding
`server-entry.mjs` as the import path, causing the server to fail to
start.
This fix reads the actual entry filename from the Vite manifest and uses
it in the generated `server.js` import, falling back to
`server-entry.mjs` when no custom naming is configured.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
closes#3391
---
Generated PR message:
Fix base path handling for assets in plugin-vite
Fixes issue where Fresh apps mounted at non-root paths (e.g., /ui) in
frameworks like Hono would fail to load assets correctly.
Problem
When mounting a Fresh app with app.mount('/ui', UI.fetch), the HTML
would load but all assets (CSS, JS, images) would return 404 because
asset paths
were hardcoded to start with /assets/ instead of respecting the Vite
base configuration.
Solution
- Modified packages/plugin-vite/src/plugins/server_entry.ts to read
Vite's base config and apply it to asset paths
- Added getAssetPath() helper function to construct proper asset URLs
with base path
- Updated both CSS and asset file registration to use the base path
Testing
Added comprehensive test case "vite build - base path asset handling"
that:
- Builds demo with custom base path /my-app/
- Verifies generated server.js contains correctly prefixed asset paths
- Follows existing test patterns and utilities
Usage
Users can now properly mount Fresh apps by configuring both:
```ts
// vite.config.ts
export default defineConfig({
base: "/ui/",
plugins: [fresh()],
});
// main.ts
const app = new App({ basePath: "/ui" });
// hono-app.ts
app.mount('/ui', UI.fetch); // Assets now work correctly
```
Backward compatible - no changes needed for apps mounted at root path.
Fix#3232
Disclaimer: This code was mostly generated by GitHub Copilot agent using
Sonnet-4, but tested and verified by me.
---------
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.