Skip to content

Commit a35a13d

Browse files
committed
generate languages metadata
1 parent 6dbae78 commit a35a13d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

vite.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
33
import vue from '@vitejs/plugin-vue'
44
import { VitePWA } from 'vite-plugin-pwa'
55
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
6+
import fs from 'node:fs'
67
import path from 'node:path'
78
import { description, appDeployName } from './package.json'
89
import legacy from '@vitejs/plugin-legacy'
@@ -61,6 +62,18 @@ export default defineConfig({
6162
include: [path.resolve(__dirname, './src/locales/**')],
6263
strictMessage: false
6364
}),
65+
// generate languages.json metadata for the brdgm.github.io game index
66+
{
67+
name: 'generate-languages-json',
68+
writeBundle() {
69+
const localesDir = path.resolve(__dirname, './src/locales')
70+
const languages = fs.readdirSync(localesDir)
71+
.filter(f => f.endsWith('.json'))
72+
.map(f => f.replace('.json', ''))
73+
const outDir = path.resolve(__dirname, './dist')
74+
fs.writeFileSync(path.resolve(outDir, 'languages.json'), JSON.stringify(languages))
75+
}
76+
},
6477
// support older browsers
6578
legacy({
6679
modernTargets: 'iOS >= 15, Safari >= 15',

0 commit comments

Comments
 (0)