Skip to content

fix(start-plugin-core): stop eclipsing user's rsbuild output.assetPrefix#7828

Closed
alexandre-marchina wants to merge 2 commits into
TanStack:mainfrom
alexandre-marchina:main
Closed

fix(start-plugin-core): stop eclipsing user's rsbuild output.assetPrefix#7828
alexandre-marchina wants to merge 2 commits into
TanStack:mainfrom
alexandre-marchina:main

Conversation

@alexandre-marchina

@alexandre-marchina alexandre-marchina commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #7827.

Summary

This PR uses api.getRsbuildConfig('original') to detect real user intent, and only writes to the client environment when the user set output.assetPrefix or server.base. The server.base precedence path is preserved.

Summary by CodeRabbit

  • New Features
    • Added support for explicitly configuring an asset prefix for client-side resources.
    • Supports automatic asset prefixing, relative paths, and complete URLs.
    • Preserves configured public base paths when no explicit asset prefix is provided.
    • Leaves default root-based configurations unchanged so platform defaults continue to apply.
  • Bug Fixes
    • Prevented client asset prefix settings from being applied to server-rendered resources.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Rsbuild environment planner now accepts an optional asset prefix, preserves explicit user configuration, avoids writing a default client override, and keeps the SSR asset prefix unset. Tests cover default, path, automatic, and URL values.

Changes

Asset prefix handling

Layer / File(s) Summary
Client asset prefix derivation and validation
packages/start-plugin-core/src/rsbuild/planning.ts, packages/start-plugin-core/tests/rsbuild/output-directory.test.ts
The planner selects explicit assetPrefix, non-default publicBase, or undefined for the client environment, while SSR remains unset; tests cover these cases.
Explicit configuration forwarding
packages/start-plugin-core/src/rsbuild/plugin.ts
The plugin checks the original Rsbuild config and forwards assetPrefix to the planner only when it was explicitly configured.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: schiller-manuel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes match issue #7827 by avoiding default client assetPrefix writes and forwarding explicit values with tests.
Out of Scope Changes check ✅ Passed The PR stays focused on rsbuild assetPrefix handling and related tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving the user's rsbuild output.assetPrefix instead of overriding it.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/start-plugin-core/tests/rsbuild/output-directory.test.ts (1)

200-207: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Assert that assetPrefix is absent for all server environments.

The Rsbuild environment plan statically adds the base server environment and dynamically adds the ssr (provider) environment based on the configuration. You can optionally strengthen this test by asserting that neither of the server environments receives an assetPrefix.

♻️ Proposed refactor
   test('server environment never gets an assetPrefix', () => {
     const plan = createRsbuildEnvironmentPlan({
       ...baseOptions,
       assetPrefix: 'https://cdn.example.com/',
     })
     expect(plan.environments.ssr!.output?.assetPrefix).toBeUndefined()
+    expect(plan.environments.server!.output?.assetPrefix).toBeUndefined()
   })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/start-plugin-core/tests/rsbuild/output-directory.test.ts` around
lines 200 - 207, Strengthen the server asset-prefix test around
createRsbuildEnvironmentPlan by asserting that assetPrefix is undefined for both
the statically added server environment and the dynamically configured ssr
environment. Keep the existing CDN input and assertions for non-server behavior
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/start-plugin-core/tests/rsbuild/output-directory.test.ts`:
- Around line 200-207: Strengthen the server asset-prefix test around
createRsbuildEnvironmentPlan by asserting that assetPrefix is undefined for both
the statically added server environment and the dynamically configured ssr
environment. Keep the existing CDN input and assertions for non-server behavior
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f94d03c3-2333-4b1f-8697-838aa3be5fab

📥 Commits

Reviewing files that changed from the base of the PR and between 0b178a7 and 087f2f0.

📒 Files selected for processing (3)
  • packages/start-plugin-core/src/rsbuild/planning.ts
  • packages/start-plugin-core/src/rsbuild/plugin.ts
  • packages/start-plugin-core/tests/rsbuild/output-directory.test.ts

@LadyBluenotes

Copy link
Copy Markdown
Member

We only review implementation PRs after the underlying issue has been reproduced, triaged, and the scope has been agreed with a maintainer. Please include a minimal reproduction in the PR and wait for maintainer confirmation before submitting a fix. I’m closing this PR for now; we can revisit it once the issue is confirmed

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.

[@tanstack/react-start/plugin/rsbuild] tanstackStart() eclipses the client environment's output.assetPrefix, blocking downstream plugins

3 participants