Refactor(files-util): Optimize the regular expression to match "import react"

This commit is contained in:
2024-09-13 09:18:57 +08:00
parent 92115d3faa
commit 72ab390756

View File

@@ -106,7 +106,7 @@ export const cssToJs = (file: IFile) => {
}
export const addReactImport = (code: string) => {
if (!/import\s+React/g.test(code)) {
if (!/^\s*import\s+React\s+/g.test(code)) {
return `import React from 'react';\n${code}`
}
return code