I am using react web app using vite as build tool
after building my application all the assets ( js, css, svg, png, jpg ) generated in build folder
in vite config i defined base: https://x.y.com
in this case all the assets will be dowloaded from the above base url
Ex:
https://x.y.com/assets/index.asdasd.js
https://x.y.com/assets/print.qwjhgkjf.svg
it works totally fine.
But what I have now is all my assets are in 2 different cdns
- all image assets are in https://img.x.com/…
- all other assets are in https://js.x.com/….
I have to configure vite as below
experimental: {
renderBuiltUrl(filename: string, { hostId, hostType, type }) {
const paths = filename.split('.');
const ext = paths[paths.length - 1];
if (hostType !== 'html') {
if (imgExt[ext]) {
return { runtime: 'https://img.x.com' };
}
return { runtime: 'https://js.x.com' };
} else {
return { relative: true };
}
}
but it is throwing me error that
[vite:css-post] { runtime: "https://img.x.com/ }" is not supported for assets in css files: assets/leftArrow.e0fcee6e.svg
error during build:
Error: { runtime: "https://img.x.com/ }" is not supported for assets in css files: assets/leftArrow.e0fcee6e.svg