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