Skip to content

Commit

Permalink
Fix HMR issue when resources/lang directory doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Feb 19, 2024
1 parent f2f0918 commit 38c63f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const refreshPaths = [
'resources/lang/**',
'resources/views/**',
'routes/**',
]
].filter(path => fs.existsSync(path.replace(/\*\*$/, '')))

/**
* Laravel plugin for Vite.
Expand Down
18 changes: 17 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import laravel from '../src'
import { resolvePageComponent } from '../src/inertia-helpers';

vi.mock('fs', async () => {
const actual = await vi.importActual<typeof import('fs')>('fs')

return {
default: {
...actual,
existsSync: (path: string) => [
'app/Livewire/',
'app/View/Components/',
'resources/views/',
'lang/',
'routes/'
].includes(path) || actual.existsSync(path)
}
}
})

describe('laravel-vite-plugin', () => {
afterEach(() => {
vi.clearAllMocks()
Expand Down Expand Up @@ -317,7 +334,6 @@ describe('laravel-vite-plugin', () => {
'app/Livewire/**',
'app/View/Components/**',
'lang/**',
'resources/lang/**',
'resources/views/**',
'routes/**',
],
Expand Down

0 comments on commit 38c63f7

Please sign in to comment.