Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Request to support renderBuiltUrl like vite #2741

Open
zydmayday opened this issue Jul 1, 2024 · 3 comments
Open

[Feature]: Request to support renderBuiltUrl like vite #2741

zydmayday opened this issue Jul 1, 2024 · 3 comments

Comments

@zydmayday
Copy link

zydmayday commented Jul 1, 2024

What problem does this feature solve?

We are currently using vite and have this config in our app.
refer doc: https://vitejs.dev/guide/build.html#advanced-base-options
-> experimental.renderBuiltUrl

I searched in doc and there is no renderBuiltUrl in rebuild.
So even I followed the migration doc(https://rsbuild.dev/guide/migration/vite) and finished most of them,
finally I stucked with "experimental.renderBuiltUrl".

So I wonder if rsbuild is going to support this feature or not,
or if you have any alternatives to this.
Thanks!

// some sample code
// in our vite.config.js
experimental: {
  renderBuildUrl(filename, { hostType }) {
    if (['css', 'js'].includes(hostType)) {
      return {runtime: window.__getFile(filename)}
    }
    return {relative: true}
  }
}
// in our index.html
<script>
  window.__getFile = function (file) {
    return `${window.OTHERS.PREFIX}/${file}`;
  }
</script>

What does the proposed API look like?

I would like to have the same feature with what vite currently has.
Or if you can design with a better way.

vite doc to refer: https://vitejs.dev/guide/build.html#advanced-base-options

Let me know if you need more information.

@chenjiahan
Copy link
Member

Rsbuild should provide an alternative feature for this, we will try to design and implement it.

@9aoy
Copy link
Contributor

9aoy commented Sep 27, 2024

In Rsbuild, you can configure the static assets prefix url through dev.assetPrefix / output.assetPrefix, and configure the base path of index.html and public dir through sever.base(WIP), see #3542.

@zydmayday
Copy link
Author

@9aoy
Hi that's awesome!!
btw, we still need to have support of {runtime: window.__getFile(filename)} before we can go from vite to rsbuild.
But really appreciate to your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants