Skip to content

Commit

Permalink
fix: add RefreshSig to refresh content regex (closes #52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jan 25, 2023
1 parent 48017b7 commit c8dd1d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ declare module 'vite' {
}

const prependReactImportCode = "import React from 'react'; "
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/

export default function viteReact(opts: Options = {}): PluginOption[] {
// Provide default values for Rollup compat.
Expand Down Expand Up @@ -335,7 +336,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {

if (result) {
let code = result.code!
if (useFastRefresh && /\$RefreshReg\$\(/.test(code)) {
if (useFastRefresh && refreshContentRE.test(code)) {
code = addRefreshWrapper(code, id)
}
return {
Expand Down

0 comments on commit c8dd1d6

Please sign in to comment.