| 1 | import type { Plugin } from 'vite' |
| 2 | import { regexSlideSourceId } from './common' |
| 3 | |
| 4 | /** |
| 5 | * force reload slide component to ensure v-click resolves correctly |
| 6 | */ |
| 7 | export function createHmrPatchPlugin(): Plugin { |
| 8 | return { |
| 9 | name: 'slidev:hmr-patch', |
| 10 | transform: { |
| 11 | filter: { |
| 12 | id: { |
| 13 | include: regexSlideSourceId, |
| 14 | }, |
| 15 | }, |
| 16 | handler(code, id) { |
| 17 | if (!id.match(regexSlideSourceId)) |
| 18 | return |
| 19 | return code.replace('if (_rerender_only)', 'if (false)') |
| 20 | }, |
| 21 | }, |
| 22 | } |
| 23 | } |
| 24 |