Add cache busting to web components CDN URLs

This commit is contained in:
Torsten Dittmann
2025-11-05 12:36:17 +04:00
parent 90ecabb295
commit f04245b225
+3 -2
View File
@@ -10,8 +10,9 @@ const COMPONENT_SELECTOR = 'imagine-web-components-wrapper[data-appwrite-studio]
const STYLE_ATTRIBUTE = 'data-appwrite-studio-style';
const BLOCK_START_BASE_OFFSET = 48;
const INLINE_START_BASE_OFFSET = 8;
const CACHE_BUSTER = new Date().getTime();
const CDN_URL =
'https://esm.sh/@imagine.dev/web-components@0/web-components?bundle=false&deps=react@19.1.0,react-dom@19.1.0&cache=' + new Date().getTime();
'https://esm.sh/@imagine.dev/web-components@0/web-components?bundle=false&deps=react@19.1.0,react-dom@19.1.0&cache=' + CACHE_BUSTER;
const DEV_OVERRIDE_WEB_COMPONENTS = env?.PUBLIC_AI_OVERRIDE_WEB_COMPONENTS === 'true';
let component: HTMLElement | null = null;
@@ -90,7 +91,7 @@ function injectStyles(node: HTMLElement, attempt = 0) {
link.rel = 'stylesheet';
link.href = DEV_OVERRIDE_WEB_COMPONENTS
? DEV_CSS_URL
: 'https://esm.sh/@imagine.dev/web-components@0/imagine-web-components.css';
: 'https://esm.sh/@imagine.dev/web-components@0/imagine-web-components.css?cache=' + CACHE_BUSTER;
link.setAttribute(STYLE_ATTRIBUTE, 'true');
shadow.prepend(link);
})