mirror of
https://github.com/thelittlerocket/rss-to-email.git
synced 2025-01-31 13:27:45 +08:00
7a46bd34a0
* Handle errors better and clear cache when updating feeds.ts
21 lines
545 B
TypeScript
21 lines
545 B
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { existsSync, unlinkSync } from 'fs'
|
|
|
|
const cachePath = './cache.json'
|
|
|
|
const FeedCacheHmr = () => ({
|
|
name: 'feed-cache-hmr',
|
|
enforce: 'pre' as const,
|
|
handleHotUpdate({ file }) {
|
|
// If the feeds.ts file is updated, remove the cached version
|
|
if (file.endsWith('src/feeds.ts') && existsSync(cachePath)) {
|
|
unlinkSync(cachePath)
|
|
}
|
|
},
|
|
})
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react(), FeedCacheHmr()],
|
|
})
|