npm add @empjs/plugin-react -D
import pluginReact from '@empjs/plugin-react'
import {defineConfig} from '@empjs/cli'
export default defineConfig(({mode, env}) => {
return {
plugins: [pluginReact()],
}
})
import pluginReact from '@empjs/plugin-react'
import {defineConfig} from '@empjs/cli'
export default defineConfig(({mode, env}) => {
return {
plugins: [pluginReact({hmr: true})],
}
})
import LogoComponent from 'src/assets/logo.svg?react'
//使用
<LogoComponent className="logo" />
//ts集成
declare module '*.svg?react' {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
export default ReactComponent
}
自定义配置
import pluginReact from '@empjs/plugin-react'
import {defineConfig} from '@empjs/cli'
export default defineConfig(({mode, env}) => {
return {
plugins: [pluginReact({svgrQuery: 'react'})],
}
})