Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在路由/反应生成与开发中未显示图像_Reactjs_Webpack_React Routing - Fatal编程技术网

Reactjs 在路由/反应生成与开发中未显示图像

Reactjs 在路由/反应生成与开发中未显示图像,reactjs,webpack,react-routing,Reactjs,Webpack,React Routing,我试图让我的图像出现在我的react代码的构建版本中 ```import reportIcon from "../../../../../src/img/reportmanager.svg"; <img src={reportIcon } className="img-icons-list" />``` 我需要把 在我的react项目的index.html中 ```const HtmlWebPackPlugin = require("html-webpack-plugin");

我试图让我的图像出现在我的react代码的构建版本中

```import reportIcon from "../../../../../src/img/reportmanager.svg"; 
<img src={reportIcon } className="img-icons-list" />```
我需要把

在我的react项目的index.html中

```const HtmlWebPackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path');
module.exports = {
entry: './src/index.js',
output: {
    path: path.resolve(__dirname + '/public'),
    filename: 'bundle.js'
},
module: {
    rules: [
        {
            test: /\.(js|jsx)$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            options: {
                presets: ['@babel/preset-env',
                    '@babel/react', {
                        'plugins': ['@babel/plugin-proposal-class-properties']
                    }]
            },
        },
        {
            test: /\.css$/,
            use: ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: "css-loader"
            })
        },
        {
            test: /\.(eot|ttf|woff|woff2)$/,
            loader: 'file-loader?name=./font/[name]_[hash:7].[ext]'
        },
        {
            test: /\.(jpg|png|svg)$/,
            loader: 'file-loader?name=./img/[name]_[hash:7].[ext]'
        }

    ]
},
devServer: {
    historyApiFallback: {
        index: "/",
    }
},
plugins: [
    new ExtractTextPlugin("css/style.css"),
    new HtmlWebPackPlugin({
        template: "./src/index.html",
        filename: "./index.html"
    }),
    function () {
        this.plugin("done", function (stats) {
            if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1) {
                console.log(stats.compilation.errors);
                process.exit(1); // or throw new Error('webpack build failed.');
            }
            // ...
        });
    }
]
};