使用webpack时如何在控制台上跟踪reactjs错误?

时间:2019-05-06 09:00:11

标签: reactjs webpack

我正在将React与Web Pack一起使用,但无法在控制台上跟踪React错误。 我已经安装了“ npm-watch”,只要进行任何更改,它都可以正常工作,但是我无法在控制台上跟踪react错误。

这是我的webpack.config.js文件

const HtmlWebPackPlugin = require("html-webpack-plugin");

    module.exports = {
      entry: './src/index.js',
      module: {
        rules: [
          {
            test: /\.(js|jsx)$/,
            exclude: /node_modules/,
            use: ['babel-loader']
          },
          {
            test:/\.css$/,
            use:['style-loader','css-loader']
          },
          {
            test: /\.(png|jp(e*)g|svg)$/,  
            use: [{
                loader: 'url-loader',
                options: { 
                    limit: 80000, // Convert images < 8kb to base64 strings
                    name: 'src/[name].[ext]'
                } 
            }]
        }
        ]
      },
      resolve: {
        extensions: ['*', '.js', '.jsx']
      },
      output: {
        path: __dirname + '/dist',
        publicPath: '/',
        filename: 'bundle.js'
      },
      plugins: [
        new HtmlWebPackPlugin({
          template: "./public/index.html",
          filename: "./index.html",
          favicon: './public/favicon.ico' 
        })
      ],
      devServer: {
        contentBase: './dist'
      },
      watchOptions: {
        poll: true,
        ignored: /node_modules/
      }
    };

0 个答案:

没有答案