Skip to content

feat(vite-plugin): add build.rewriteBase for remote miniapps - #258

Merged
Gaubee merged 1 commit into
mainfrom
feat/miniapp-rewrite-base-clean
Jan 20, 2026
Merged

Gaubee merged 1 commit into
mainfrom
feat/miniapp-rewrite-base-clean

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add server/build config structure to RemoteMiniappConfig for dev/build mode separation
  • Implement rewriteHtmlBase() function to inject <base> tag in index.html
  • Apply base rewrite after copying to dist (build mode only)
  • Configure rwa-hub with build.rewriteBase: true

Problem

Remote miniapps like rwa-hub are built with base: '/' but deployed under /miniapps/rwa-hub/. This causes all relative resource paths to break (404 errors for /assets/xxx.js).

Solution

In build mode, after copying the remote miniapp to dist, rewrite index.html to inject:

<base href="/miniapps/rwa-hub/">

This makes all relative paths resolve correctly.

Configuration

remoteMiniappsPlugin({
  miniapps: [
    {
      metadataUrl: '...',
      dirName: 'rwa-hub',
      build: {
        rewriteBase: true,  // auto-infer '/miniapps/rwa-hub/'
        // or: rewriteBase: '/custom/path/'
      },
    },
  ],
})

Next Steps

After this PR is merged, PR2 will add wujie runtime support with similar server.runtime / build.runtime configuration.

- Add server/build config structure to RemoteMiniappConfig
- Implement rewriteHtmlBase function to inject <base> tag in index.html
- Apply base rewrite after copying to dist (build mode only)
- Configure rwa-hub with build.rewriteBase: true

This fixes baseUrl issues for remote miniapps deployed under /miniapps/{dirName}/
@Gaubee
Gaubee force-pushed the feat/miniapp-rewrite-base-clean branch from 9ba64b3 to 68a9681 Compare January 20, 2026 18:07
@Gaubee
Gaubee merged commit e233cf9 into main Jan 20, 2026
5 checks passed
@Gaubee
Gaubee deleted the feat/miniapp-rewrite-base-clean branch January 20, 2026 18:10
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.

1 participant