Repository navigation
Fix Vite asset import rewriting for template literal strings - #1010
Oussemasahbeni wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReordered imports in Changes
🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Thank you for the PR.
Please add a test case here: https://github.com/keycloakify/keycloakify/blob/main/test/bin/replacers.spec.ts
Thank you for your contribution.
|
@garronej done |
|
Let's create a release candidate to make sure the fix works |
|
Superseeded by #1012 |
Fixes a JS asset rewrite miss in the Vite Keycloakify build flow.
replaceImportsInJsCode_vitewas only rewriting asset imports when Vite emitted them as double-quoted string literals, for example:"/assets/auth-logo-BR8ovgvV.svg"Starting with Vite 8, the generated JS can emit the same asset path as a template literal instead:
`/assets/auth-logo-BR8ovgvV.svg`When that happens, the rewrite step is skipped, so the generated Keycloak theme JS keeps /assets/... URLs instead of rewriting them to the Keycloak theme resources path.

This causes runtime-imported assets such as logos or SVG illustrations to 404 in Keycloak even though the files are bundled correctly in the theme JAR.
Example broken output:
In Keycloak, those assets need to resolve through:
${window.kcContext["x-keycloakify"].resourcesPath}/dist/assets/...To fix that we need to xtend the Vite JS import replacer so it rewrites exact asset literals wrapped in any standard JS string delimiter:
`...`Summary by CodeRabbit
Refactor
Tests