feat: localizations
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+26
-3
@@ -1,10 +1,30 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, type PluginOption } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
|
||||
// Copy translation catalogs (l10n/*.json, except the extractor-only
|
||||
// en.manual.json) into static/l10n/ so the core shell can fetch them at
|
||||
// /modules/{handle}/static/l10n/{locale}.json
|
||||
const copyL10nCatalogs = (): PluginOption => ({
|
||||
name: 'copy-l10n-catalogs',
|
||||
apply: 'build',
|
||||
closeBundle() {
|
||||
const sourceDir = path.resolve(__dirname, 'l10n')
|
||||
const outDir = path.resolve(__dirname, 'static/l10n')
|
||||
if (!fs.existsSync(sourceDir)) return
|
||||
fs.mkdirSync(outDir, { recursive: true })
|
||||
for (const file of fs.readdirSync(sourceDir)) {
|
||||
if (file.endsWith('.json') && !file.endsWith('.manual.json')) {
|
||||
fs.copyFileSync(path.join(sourceDir, file), path.join(outDir, file))
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
plugins: [vue(), copyL10nCatalogs()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
@@ -20,7 +40,10 @@ export default defineConfig({
|
||||
fileName: () => 'module.mjs',
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['vue', 'vue-router', 'pinia'],
|
||||
external: ['vue', 'vue-router', 'pinia', '@KTXC'],
|
||||
output: {
|
||||
paths: (id) => (id === '@KTXC' ? '/js/ktxc.mjs' : id),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user