Skip to content

Commit 4e85612

Browse files
authored
fix: handle vite restart (#138)
1 parent ae2bcc0 commit 4e85612

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/vite.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function i18n(langPath: string = 'lang'): Plugin {
1212
let exitHandlersBound: boolean = false
1313

1414
const clean = () => {
15+
console.log('clean')
1516
files.forEach((file) => unlinkSync(langPath + file.name))
1617

1718
files = []
@@ -25,12 +26,6 @@ export default function i18n(langPath: string = 'lang'): Plugin {
2526
name: 'i18n',
2627
enforce: 'post',
2728
config(config) {
28-
if (!hasPhpTranslations(frameworkLangPath) && !hasPhpTranslations(langPath)) {
29-
return
30-
}
31-
32-
files = generateFiles(langPath, [...parseAll(frameworkLangPath), ...parseAll(langPath)])
33-
3429
/** @ts-ignore */
3530
process.env.VITE_LARAVEL_VUE_I18N_HAS_PHP = true
3631

@@ -41,6 +36,13 @@ export default function i18n(langPath: string = 'lang'): Plugin {
4136
}
4237
},
4338
buildEnd: clean,
39+
buildStart() {
40+
if (!hasPhpTranslations(frameworkLangPath) && !hasPhpTranslations(langPath)) {
41+
return
42+
}
43+
44+
files = generateFiles(langPath, [...parseAll(frameworkLangPath), ...parseAll(langPath)])
45+
},
4446
handleHotUpdate(ctx) {
4547
if (/lang\/.*\.php$/.test(ctx.file)) {
4648
files = generateFiles(langPath, [...parseAll(frameworkLangPath), ...parseAll(langPath)])

0 commit comments

Comments
 (0)