how to set up an inline svg with webpack

后端 未结 9 1924
感动是毒
感动是毒 2020-12-02 16:49

I am wondering how to set up an inline svg with webpack?

I am following the react-webpack-cookbook.

I have my webpack.config set up correc

9条回答
  •  长情又很酷
    2020-12-02 17:18

    @svgr/webpack (npm) is the inline svg loader that create-react-app uses.

    Add the rule to your webpack config:

    {
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    }
    

    Then you can import svgs as React components:

    import Star from './star.svg'
    
    const App = () => (
      
    )

提交回复
热议问题