refactor: replace CDN_URL with CDN_HOST in Dockerfiles and update related scripts for asset loading

This commit is contained in:
Victor Santos
2025-12-12 14:00:59 -03:00
parent 64f566076b
commit cce59e3bf6
4 changed files with 19 additions and 19 deletions

View File

@@ -29,11 +29,11 @@ export default defineConfig(({ mode }) => {
"0.0.1"
).replaceAll(".", "-");
// CDN URL for static assets in /assets/* only.
// Docker: Set CDN_URL env var at runtime (placeholder replaced at container startup).
// Direct build: Use --build-arg CDN_URL=https://... or VITE_CDN_URL env var.
// CDN HOST for static assets in /assets/* only.
// Docker: Set CDN_HOST env var at runtime (placeholder replaced at container startup).
// Direct build: Use --build-arg CDN_HOST=https://... or VITE_CDN_HOST env var.
// Default: Empty = same-origin asset loading.
const cdnUrl = env.VITE_CDN_URL || "";
const cdnHost = env.VITE_CDN_HOST || "";
return {
base: "/",
@@ -60,10 +60,10 @@ export default defineConfig(({ mode }) => {
}
},
experimental: {
// Only apply CDN URL to files in /assets/* directory
// Only apply CDN HOST to files in /assets/* directory
renderBuiltUrl(filename) {
if (filename.startsWith("assets/") && cdnUrl) {
return `${cdnUrl}/${filename}`;
if (filename.startsWith("assets/") && cdnHost) {
return `${cdnHost}/${filename}`;
}
return `/${filename}`;
}