fix(frontend): resolve lazy chunk URLs against runtime base path

Vite's default chunk-preload helper prepends a hardcoded `/` to asset
filenames, so dynamic chunk preloads always 404 when the panel is
served under a non-root webBasePath (e.g. /CxuVUNgm5mRLmjPhp3/). Use
experimental.renderBuiltUrl to embed window.X_UI_BASE_PATH (injected
by dist.go) as the runtime prefix, so __vite__mapDeps emits URLs like
`<basePath>assets/<file>` regardless of where the dist is mounted.
This commit is contained in:
MHSanaei 2026-05-23 20:49:09 +02:00
parent 120898ee09
commit c6d451bcf0
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -152,6 +152,16 @@ export default defineConfig({
'@': path.resolve(__dirname, 'src'), '@': path.resolve(__dirname, 'src'),
}, },
}, },
experimental: {
renderBuiltUrl(filename, { hostType }) {
if (hostType === 'js') {
return {
runtime: `((window.X_UI_BASE_PATH||'/')+${JSON.stringify(filename)})`,
};
}
return undefined;
},
},
build: { build: {
outDir, outDir,
emptyOutDir: true, emptyOutDir: true,