why this vite config not creating index.html per locale inside code folder in build? fix…
- User
why this vite config not creating index.html per locale inside code folder in build? fix it!
import { defineConfig } from 'vite'; import { resolve } from 'path'; import { createHtmlPlugin } from 'vite-plugin-html'; import fs from 'fs';
const RTL_LOCALES = ['he'] const localesDir = resolve(__dirname, 'public/locales') const translations = fs.readdirSync(localesDir).reduce((acc, file) => { const match = file.match(/^([a-zA-Z-_]+).json$/); if (match) { const locale = match[1]; const content = JSON.parse(fs.readFileSync(resolve(localesDir, file), 'utf-8')); acc[locale] = content; } return acc; }, {} as Record<string, any>); const locales = Object.keys(translations);
export default defineConfig({ root: '.', publicDir: 'public', assetsInclude: [ '/*.fbx', '/.tga.png' ], define: { LANGS: JSON.stringify(locales) // TODO fix }, build: { outDir: 'out', emptyOutDir: true, assetsDir: 'res', sourcemap: true, rollupOptions: { output: { entryFileNames: 'bundle.[hash].js', chunkFileNames: 'chunk.[hash].js', assetFileNames: '[name].[hash][extname]' } }, }, css: { devSourcemap: true, modules: false }, plugins: [ createHtmlPlugin({ pages: locales.map(locale => ({ entry: 'src/main.ts', template: 'index.html', filename: , minify: true, injectOptions: { data: { locale, locales, dir: RTL_LOCALES.includes(locale) ? 'rtl' : 'ltr', ...translations[locale] } } })), }) ], resolve:{ alias:{ "@": resolve(__dirname, './src') } }, server:{ port:8080 } });
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.