Skip to content

Commit

Permalink
feat(web-component): add base-cdn-url attribute (#1013)
Browse files Browse the repository at this point in the history
## Related Issues

Fixes descope/etc#9009

Adding a way to customize CDN
  • Loading branch information
omercnet authored Feb 10, 2025
1 parent ee9199c commit 8346412
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const descopeUiMixin = createSingletonMixin(
this.#registerEvents(scriptEle);

scriptEle.src = generateScriptUrl(
UI_COMPONENTS_URL,
this.baseCdnUrl || UI_COMPONENTS_URL,
await this.#getComponentsVersion(),
);
} else {
Expand Down Expand Up @@ -241,6 +241,10 @@ export const descopeUiMixin = createSingletonMixin(
});
});
}

get baseCdnUrl() {
return this.getAttribute('base-cdn-url');
}
};
},
);
11 changes: 11 additions & 0 deletions packages/sdks/web-component/rollup.config.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export default {
'process.env.DESCOPE_FLOW_ID': JSON.stringify(
process.env.DESCOPE_FLOW_ID || '',
),
'process.env.DESCOPE_BASE_STATIC_URL': JSON.stringify(
process.env.DESCOPE_BASE_STATIC_URL || '',
),
'process.env.DESCOPE_BASE_CDN_URL': JSON.stringify(
process.env.DESCOPE_BASE_CDN_URL || '',
),
},
}),
del({ targets: 'build' }),
Expand All @@ -48,6 +54,11 @@ export default {
.replace('<project-id>', process.env.DESCOPE_PROJECT_ID || '')
.replace('<flow-id>', process.env.DESCOPE_FLOW_ID || 'sign-up-or-in')
.replace('<base-url>', process.env.DESCOPE_BASE_URL || '')
.replace(
'<base-static-url>',
process.env.DESCOPE_BASE_STATIC_URL || '',
)
.replace('<base-cdn-url>', process.env.DESCOPE_BASE_CDN_URL || '')
.replace('<locale>', process.env.DESCOPE_LOCALE || ''),
}),
],
Expand Down
9 changes: 8 additions & 1 deletion packages/sdks/web-component/rollup.config.app.serve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@ import conf from './rollup.config.app.mjs';
// If TS type errors remove bs-recipes references in package-lock.json due to bad global React typings
export default {
...conf,
plugins: [...conf.plugins, browsersync({ server: 'build' })],
plugins: [
...conf.plugins,
browsersync({
server: 'build',
watch: true,
reloadOnRestart: true,
}),
],
};
2 changes: 2 additions & 0 deletions packages/sdks/web-component/src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
project-id="<project-id>"
flow-id="<flow-id>"
base-url="<base-url>"
base-static-url="<base-static-url>"
base-cdn-url="<base-cdn-url>"
locale="<locale>"
debug="true"
validate-on-blur="false"
Expand Down

0 comments on commit 8346412

Please sign in to comment.