Expect to be more flexible about build.experimental.renderBuiltUrl #18365
19Qingfeng
started this conversation in
Feedback
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
build.experimental.renderBuiltUrl
At present, it seems that this feature can only support static insertion paths during construction and use runtime like window.xxx.
In my SSR application, my CDN prefix are the CDN path obtained in the NodeServer middleware every time (which means I get a different CDN path every time a request comes).
like:
Then in the returned HTML template on server, the corresponding dynamic prefix will be spliced on the template.
Currently, such features cannot be supported on build.experimental.renderBuiltUrl.
Of course, if you mount cdnprefix on globalThis(in renderBuiltUrl.runtime), you can realize the transfer of cdnprefix, but on the server side, this will pollute global variables.
Currently due to this issue, I have to turn off modulepreload, Because I cannot get the relevant server variables in build.experimental.renderBuiltUrl.
This will cause the script address to be relative to the current page path when modulepreload is used instead of cdnprefix.
I'm not sure how vite should support this feature of dynamically obtaining cdnprefix from the server as a resource prefix now. If it doesn't, I'm not sure whether this feature is necessary to everyone, but it really cannot meet my usage scenarios at present. Unless I turn off build.modulepreload:
Currently, it does not support adding dynamic prefixes to css resources and image resources(renderBuiltUrl.runtime), It seems to work only on js resources.
Beta Was this translation helpful? Give feedback.
All reactions