Replies: 8 comments 5 replies
-
When I only change renderBuildUrl function, the chunk hash will not change. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Not sure if this belongs here as it's related more to But I had this idea the other day about whether it would be possible to use import assertions to specify if an import should be preloaded. For example: const data = await import("./foo", { with: { preload: true } }); A limitation would be that the import options would have to be statically defined so that the code can be statically analyzed at compile time. |
Beta Was this translation helpful? Give feedback.
-
I have the same issue as victordidenko. Here is the basic setup I've put in place: base: "client/dist/platform"
experimental: {
renderBuiltUrl(filename: string, { hostType }: { hostType: "js" | "css" | "html" }) {
if (hostType === "js") {
return { runtime: `window.buildUrl(${JSON.stringify(filename)})` };
} else {
return { relative: true };
}
}
} And in my index.html I have (for my test): ...
<script>
window.buildUrl = (filename) => {
return `https://myCdnUrl/client/dist/platform/${filename}`
}
</script>
.... When I'm navigating into my app on I pushed a bit further in my testing, putting the same string in my buildUrl function i.e.:
In this case I don't see double loading of js assets and assets are all (or almost all) imported using the preload imports. Do you have any idea of what can cause this duplication in js assets import. |
Beta Was this translation helpful? Give feedback.
-
I want to give feedback that this feature is excellent for fixing asset paths when developing browser extensions. More context in crxjs/chrome-extension-tools#842 (comment). |
Beta Was this translation helpful? Give feedback.
-
I have a mutiple entry app, and i want build app only once,but i cant get the assets's entry in this config😭 |
Beta Was this translation helpful? Give feedback.
-
Just tried this. Works really well to enable runtime injection of assets path – we use it to build feature preview support where assets might be stored in a different bucket. |
Beta Was this translation helpful? Give feedback.
-
Just what I needed, in our case we use a base url pointing to our CDN, so doing |
Beta Was this translation helpful? Give feedback.
-
renderBuiltUrl
Open question: Should we move it from experimental to a vite-specific hook or to a config option in
build
.We're looking to stabilize this feature in Vite 5. If you have feedback about it, let's use this discussion to gather it.
Beta Was this translation helpful? Give feedback.
All reactions