mirror of
https://github.com/Afilmory/afilmory
synced 2026-05-02 18:57:20 +00:00
- Introduced multiple Vite plugins including `ogImagePlugin`, `feedSitemapPlugin`, `localesJsonPlugin`, and `manifestInjectPlugin` to enhance the build process and support dynamic content generation. - Implemented a custom hot module replacement (HMR) for JSON localization files to improve development experience. - Added a new `createDependencyChunksPlugin` for better chunk management in the build process. - Established a structure for handling localization files and generating corresponding assets, improving internationalization support. Signed-off-by: Innei <tukon479@gmail.com>
25 lines
558 B
TypeScript
25 lines
558 B
TypeScript
import { readFileSync } from 'node:fs'
|
|
|
|
import type { Plugin } from 'vite'
|
|
|
|
export function customI18nHmrPlugin(): Plugin {
|
|
return {
|
|
name: 'custom-i18n-hmr',
|
|
handleHotUpdate({ file, server }) {
|
|
if (file.endsWith('.json') && file.includes('locales')) {
|
|
server.ws.send({
|
|
type: 'custom',
|
|
event: 'i18n-update',
|
|
data: {
|
|
file,
|
|
content: readFileSync(file, 'utf-8'),
|
|
},
|
|
})
|
|
|
|
// return empty array to prevent the default HMR
|
|
return []
|
|
}
|
|
},
|
|
}
|
|
}
|