Skip to content

Commit

Permalink
fix(vite): respect reload watch options
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Feb 16, 2022
1 parent ac1fc8d commit 980ba55
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions vite-plugin-laravel/src/reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ export const reload = (options: Options = {}): Plugin => {

// When the config change, we want a full module graph
// invalidation as well as a full reload
watchOptions.input.push({
condition: (file) => file.endsWith('config/vite.php'),
handle: ({ server }) => {
debug('Configuration file changed, invalidating module graph and reloading')
server.moduleGraph.invalidateAll()
server.ws.send({ type: 'full-reload', path: '*' })
},
})
if (watchOptions.reloadOnConfigUpdates) {
watchOptions.input.push({
condition: (file) => file.endsWith('config/vite.php'),
handle: ({ server }) => {
debug('Configuration file changed, invalidating module graph and reloading')
server.moduleGraph.invalidateAll()
server.ws.send({ type: 'full-reload', path: '*' })
},
})
}

// Blade files
watchOptions.input.push({
condition: (file) => file.endsWith('.blade.php'),
handle: ({ server }) => {
debug('Blade file changed, reloading')
server.ws.send({ type: 'full-reload', path: '*' })
},
})
if (watchOptions.reloadOnBladeUpdates) {
watchOptions.input.push({
condition: (file) => file.endsWith('.blade.php'),
handle: ({ server }) => {
debug('Blade file changed, reloading')
server.ws.send({ type: 'full-reload', path: '*' })
},
})
}

function handleReload(file: string, server: ViteDevServer) {
file = file.replaceAll('\\', '/')
Expand Down

0 comments on commit 980ba55

Please # to comment.