Skip to content

Commit 3a93b94

Browse files
committed
build: harden module name generation
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent fc84882 commit 3a93b94

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

build/frontend/vite.config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ export default createAppConfig(Object.fromEntries(viteModuleEntries), {
7878
entryFileNames: '[name].mjs',
7979
chunkFileNames: '[name]-[hash].chunk.mjs',
8080
assetFileNames({ originalFileNames }) {
81-
const [name] = originalFileNames
82-
if (name) {
83-
const [, appId] = name.match(/apps\/([^/]+)\//)!
84-
return `${appId}-[name]-[hash][extname]`
85-
}
86-
return '[name]-[hash][extname]'
81+
const apps = originalFileNames.map((name) => name.match(/apps\/([^/]+)\//)?.[1])
82+
.filter(Boolean)
83+
const appId = apps.length === 1 ? apps[0] : 'common'
84+
return `${appId}-[name]-[hash][extname]`
8785
},
8886
experimentalMinChunkSize: 100 * 1024,
8987
/* // with rolldown-vite:

0 commit comments

Comments
 (0)