Skip to content

Commit cbe6e66

Browse files
committed
fix(frontend-chat): correct groupedDocuments typing and configure Vite root/input to fix Nx build for chat-app
1 parent 5db3a92 commit cbe6e66

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

services/frontend/apps/chat-app/vite.config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default defineConfig(({ mode }) => {
1010
const envs = loadEnv(mode, CWD);
1111
return {
1212
...envs,
13+
// Ensure Vite uses the app directory as root
14+
root: fileURLToPath(new URL('./', import.meta.url)),
1315
cacheDir: '../../node_modules/.vite/chat-app',
1416
server: {
1517
port: 4200,
@@ -21,6 +23,12 @@ export default defineConfig(({ mode }) => {
2123
],
2224
},
2325
},
26+
build: {
27+
rollupOptions: {
28+
// Explicit entry to resolve index.html correctly when building via Nx
29+
input: fileURLToPath(new URL('./index.html', import.meta.url)),
30+
},
31+
},
2432
plugins: [
2533
vue(),
2634
nxViteTsPaths(),

services/frontend/libs/chat-app/ui/ChatDocumentContainer.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ const props = defineProps<{
1414
documents: Array<ChatDocumentModel>
1515
}>()
1616
17-
const groupedDocuments = computed((): ChatDocumentItemModel[] => {
18-
const documents = props.documents.map((document) => mapToDocumentItem(document));
19-
const grouped = documents.reduce(
20-
(reduced: any, element: ChatDocumentItemModel) => {
21-
reduced[element.title] = reduced[element.title] || [];
22-
reduced[element.title].push(element);
23-
return reduced;
24-
}, Object.create(null));
25-
return grouped;
17+
const groupedDocuments = computed((): Record<string, ChatDocumentItemModel[]> => {
18+
const items = props.documents.map((document) => mapToDocumentItem(document));
19+
return items.reduce((acc: Record<string, ChatDocumentItemModel[]>, element: ChatDocumentItemModel) => {
20+
if (!acc[element.title]) acc[element.title] = [];
21+
acc[element.title].push(element);
22+
return acc;
23+
}, {});
2624
});
2725
</script>
2826
<template>

0 commit comments

Comments
 (0)