rss-to-email/vite.config.ts

22 lines
545 B
TypeScript
Raw Normal View History

2023-01-20 15:54:01 +08:00
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)
}
},
})
2023-01-20 15:54:01 +08:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), FeedCacheHmr()],
2023-01-20 15:54:01 +08:00
})