Skip to content

Commit fd65b75

Browse files
committed
wip: native react refresh wrapper plugin
1 parent 1caff55 commit fd65b75

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/plugin-react/src/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,23 @@ export default function viteReact(opts: Options = {}): Plugin[] {
353353
}
354354

355355
const nativeRefreshWrapper: Plugin | undefined =
356-
// TODO: apply: 'serve'
357356
'reactRefreshWrapperPlugin' in vite
358-
? vite.reactRefreshWrapperPlugin()
357+
? {
358+
name: 'vite:react:refresh-wrapper',
359+
apply: 'serve',
360+
applyToEnvironment(env) {
361+
return env.config.consumer === 'client' && !skipFastRefresh
362+
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
363+
// @ts-ignore only available in rolldown-vite
364+
vite.reactRefreshWrapperPlugin({
365+
include,
366+
exclude,
367+
jsxImportSource,
368+
reactRefreshHost: opts.reactRefreshHost ?? '',
369+
})
370+
: undefined
371+
},
372+
}
359373
: undefined
360374

361375
// for rolldown-vite

0 commit comments

Comments
 (0)