我在浏览器控制台中遇到标题错误,因为它试图将带有脚本标签的index.html文件加载到bundle.js文件中。我认为本教程指向/ dist时使用了自己的index.html和已编译的main.js文件,所以我不明白为什么我自己的bundle.js收到与缩小相关的错误:
react-dom.production.min.js:13 Uncaught Invariant Violation: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at http://localhost:8080/bundle.js:22:420
at o (http://localhost:8080/bundle.js:22:523)
at Object.render (http://localhost:8080/bundle.js:22:104077)
at Module.<anonymous> (http://localhost:8080/bundle.js:6:1229)
at P (http://localhost:8080/bundle.js:1:7211)
at http://localhost:8080/bundle.js:1:8035
at http://localhost:8080/bundle.js:1:8043
(anonymous) @ react-dom.production.min.js:13
o @ react-dom.production.min.js:14
render @ react-dom.production.min.js:266
(anonymous) @ index.jsx:16
P @ bootstrap:726
(anonymous) @ bootstrap:793
(anonymous) @ bootstrap:793
有人知道这个问题是什么吗?我的webpack.config.js如下:
const webpack = require("webpack");
const dotenvWebpack = require("dotenv-webpack");
const path = require("path");
module.exports = {
entry : {
'./adminSettingsArea' :
'./adminSettingsArea/src/index.jsx'
},
output : {
filename : '[name]/bundle.js',
path : path.resolve(__dirname),
},
devtool: 'inline-source-map',
devServer : {
"contentBase" : './adminSettingsArea',
"hot" : true
},
plugins : [
new webpack.HotModuleReplacementPlugin(),
new dotenvWebpack()
],
module : {
rules : [
{
test : /\.(js|jsx)$/,
exclude : [/node_modules/, /vendor/],
use : {
loader : "babel-loader",
options : {
presets : [
'@babel/preset-env',
"@babel/preset-react"
]
},
}
}
],
},
};