chore: extract i18n hmr plugin to base
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
5d27d29e4b
commit
9024b6a497
|
|
@ -52,6 +52,25 @@ export const viteRenderBaseConfig = {
|
|||
}),
|
||||
|
||||
viteTwToRawString(),
|
||||
|
||||
{
|
||||
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 []
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
define: {
|
||||
APP_VERSION: JSON.stringify(pkg.version),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { readFileSync } from "node:fs"
|
||||
import { resolve } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
|
|
@ -98,24 +97,6 @@ export default ({ mode }) => {
|
|||
|
||||
devPrint(),
|
||||
|
||||
{
|
||||
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 []
|
||||
}
|
||||
},
|
||||
},
|
||||
process.env.ANALYZER && analyzer(),
|
||||
],
|
||||
define: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue