Skip to content

feat(fullstack): support custom base URLs#1325

Merged
hi-ogawa merged 7 commits into
mainfrom
copilot/support-custom-base-logic
Dec 17, 2025
Merged

feat(fullstack): support custom base URLs#1325
hi-ogawa merged 7 commits into
mainfrom
copilot/support-custom-base-logic

Conversation

Copilot AI commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

Asset URLs were hardcoded with "/" prefix, preventing use of custom base paths or dynamic URL generation via renderBuiltUrl callback.

Changes

Ported asset URL generation logic from @vitejs/plugin-rsc:

  • RuntimeAsset class - Represents dynamic runtime expressions that bypass JSON stringification
  • serializeValueWithRuntime() - Serializes manifests while preserving runtime expressions as code
  • assetsURL() - Generates asset URLs respecting config.experimental.renderBuiltUrl callback, falling back to config.base + url
  • writeAssetsManifest() - Uses assetsURL() instead of hardcoded "/" for all asset paths

Example

Custom base configuration:

// vite.config.ts
export default defineConfig({
  base: '/my-app/',
  // Asset URLs now use: /my-app/assets/chunk-abc123.js
})

Dynamic URL generation:

// vite.config.ts
export default defineConfig({
  experimental: {
    renderBuiltUrl(filename) {
      return { runtime: `__CDN_BASE__ + ${JSON.stringify(filename)}` }
    }
  }
  // Manifest contains: window.__CDN_BASE__ + "assets/chunk-abc123.js"
})
Original prompt

This section details on the original issue you should resolve

<issue_title>[fullstack] support custom base</issue_title>
<issue_description>

// TODO: base
if (environmentName === "client") {
result.entry = `/${chunk.fileName}`;
result.js = deps.js.map((fileName) => ({
href: `/${fileName}`,
}));
}
result.css = deps.css.map((fileName) => ({
href: `/${fileName}`,
}));

We should be able to port this logic from @vitejs/plugin-rsc https://github.com/vitejs/vite-plugin-react/blob/3506cfa5ab086b90b8c96878f385d77762bd277c/packages/plugin-rsc/src/plugin.ts#L1793-L1822</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 17, 2025 06:13
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Copilot AI changed the title [WIP] Support custom base for fullstack plugin Support custom base URLs in fullstack plugin Dec 17, 2025
Copilot AI requested a review from hi-ogawa December 17, 2025 06:29
@hi-ogawa hi-ogawa changed the title Support custom base URLs in fullstack plugin feat(fullstack): support custom base URLs Dec 17, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review December 17, 2025 08:03
@hi-ogawa hi-ogawa merged commit 871b310 into main Dec 17, 2025
6 checks passed
@hi-ogawa hi-ogawa deleted the copilot/support-custom-base-logic branch December 17, 2025 08:08
@hi-ogawa hi-ogawa mentioned this pull request Dec 17, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fullstack] support custom base

2 participants