how to set up an inline svg with webpack

后端 未结 9 1917
感动是毒
感动是毒 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:27

    If I'm not mistaken, since you're using the file loader, you can utilize it in much the same way as any other require. Webpack will turn require("./logo.svg") into a path to a file, which it will emit when it bundles.

    import React, { Component } from 'react'
    
    import mySvg from './logo.svg'
    
    class Header extends Component {
    
      render() {
        return (
            
    ); } }; export default Header

提交回复
热议问题