Handles locales as Vite assets

This commit is contained in:
Quentin Gliech
2024-11-14 11:53:43 +01:00
parent 137a53dbee
commit 99d5886e32
32 changed files with 99 additions and 29 deletions

View File

@@ -60,6 +60,25 @@ export default defineConfig(({ mode }) => {
},
build: {
sourcemap: true,
rollupOptions: {
output: {
assetFileNames: ({ originalFileNames }) => {
if (originalFileNames) {
for (const name of originalFileNames) {
// Custom asset name for locales to include the locale code in the filename
const match = name.match(/locales\/([^/]+)\/(.+)\.json$/);
if (match) {
const [, locale, filename] = match;
return `assets/${locale}-${filename}-[hash].json`;
}
}
}
// Default naming fallback
return "assets/[name]-[hash][extname]";
},
},
},
},
plugins,
resolve: {