Replies: 12 comments 6 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.
-
I have a react web app with vite as bundling tool when i build my react web app using vite all the assets will be bundled in a build/ folder in vite config i have specified base: https://x.y.com so in my production all the assets ( js, css, svg, png, jpg .. . . ) will be downloaded with path this is working totaly fine but now my assets are deployed on 2 different cdn urls so I have to config vite such that all js files should have base url as https://x.y.cpm/index.dfgwer.js how can i do this ? |
Beta Was this translation helpful? Give feedback.
-
Really neat feature, currently doing a microfrontend, where we move the files to a specific location. This helps us point at the location its residing and saves us some work interpreting build files and generating our own html file. |
Beta Was this translation helpful? Give feedback.
-
Does it only take effect in build? Can it take effect during the development phase, because it will be nested under the micro-application |
Beta Was this translation helpful? Give feedback.
-
Hello, we tested this on a website using php for generating document and a CDN (cdn.x.com) that just sits in front of the app domain (y.com). The vite config is
and in our main document we had to expose the various assets (css,js,fonts) using the cdn domain and also define the js function for runtime
|
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