Files
lifeforge/docs/vite.config.ts
melvinchia3636 032e577732 refactor(localization): extract i18n into @lifeforge/localization package
- Create new @lifeforge/localization package with client-i18n-config, I18nInitProvider, and useModuleTranslation hook
- Rename ModuleHeaderStateProvider -> ModuleMetadataProvider and move to @lifeforge/federation
- Move I18nInitProvider from apps/web to @lifeforge/localization with configurable init/fallbacks
- Add module name to ModuleMetadataProvider context for scoped translations
- Wire up @lifeforge/localization and @lifeforge/federation as dependencies in @lifeforge/ui
- Update ModuleHeader to use useModuleTranslation for scoped i18n namespaces
- Register @lifeforge/localization in shared-packages config
- Update docs vite config with federation plugin
2026-06-25 08:53:35 +08:00

65 lines
1.4 KiB
TypeScript

import mdx, { Options } from '@mdx-js/rollup'
import react from '@vitejs/plugin-react'
import federation from '@originjs/vite-plugin-federation'
import path from 'node:path'
import remarkGfm from 'remark-gfm'
import { defineConfig } from 'vite'
import mdxListCountsPlugin from './plugins/mdxListCountsPlugin'
const options: Options = {
remarkPlugins: [remarkGfm]
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
mdx(options),
mdxListCountsPlugin(),
federation({
name: 'docs-host',
remotes: {
None: ''
},
shared: ['react', 'react-dom']
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
build: {
commonjsOptions: {
transformMixedEsModules: true
},
target: 'esnext',
sourcemap: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id
.toString()
.split('node_modules/')
.pop()!
.split('/')[0]
.toString()
} else if (id.endsWith('.mdx')) {
const mdxPath = id.toString().split('src/')[1]
return `mdx-${mdxPath.replace(/\//g, '-').replace('.mdx', '')}`
}
}
}
}
},
optimizeDeps: {
esbuildOptions: {
sourcemap: false,
target: 'esnext'
}
}
})