Skip to content

Commit

Permalink
Reload dev server on articles change
Browse files Browse the repository at this point in the history
  • Loading branch information
yen223 committed Nov 9, 2024
1 parent e22c38c commit 739eb63
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/lib/vite-plugin-articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ export function articlesPlugin(): Plugin {
'app/articles.json',
JSON.stringify(sortedArticles, null, 2)
)
},
configureServer(server) {
// Watch for changes to markdown files
server.watcher.add('articles/*.md')
server.watcher.on('change', (file) => {
if (file.endsWith('.md')) {
// Trigger rebuild when markdown files change
server.restart()
}
})
}
}
}

0 comments on commit 739eb63

Please sign in to comment.